
Code Availability
Microglial cyclooxygenase-1 modulates cerebral basal capillary tone in vivo
Code used in Supplementary Figure 6:
# Load necessary libraries
library(Seurat)
library(Matrix)
library(ggplot2)
# Load barcodes, features, and expression matrix
barcodes <- read.table(gzfile('barcodes.tsv.gz'), header = FALSE, stringsAsFactors = FALSE)
features <- read.table(gzfile('features.tsv.gz'), header = FALSE, stringsAsFactors = FALSE)
expression_matrix <- readMM(gzfile('matrix.mtx.gz'))
# Load cell annotations
cluster_membership <- read.csv('cluster.membership.csv')
cluster_annotation <- read.csv('cluster.annotation.csv')
# Merge the cluster membership and annotation to get cell type info
merged_df <- merge(cluster_membership, cluster_annotation, by.x = "x", by.y = "cluster_id", all.x = TRUE)
# Filter for glial cells (Astrocytes and Microglia)
glial_cells <- merged_df[grep("Astro|Macrophage|Oligo|OPC|Endo", merged_df$subclass_label, ignore.case = TRUE), ]
write.csv(glial_cells, "glial_cells.csv", row.names = FALSE)
# Trim white spaces from barcodes and ensure barcodes match
# Remove rows with NA or empty values
barcodes <- barcodes[!is.na(barcodes$V1) & barcodes$V1 != "", ]
barcodes_col <- trimws(barcodes$V2) # Barcodes from the expression matrix
# Clean the barcodes_col by removing the leading commas and quotes
barcodes_col_clean <- gsub('^,"|"$', '', barcodes_col)
# Check if the cleaning worked
head(barcodes_col_clean)
glial_barcodes <- trimws(glial_cells$X) # Barcodes from glial cells
head(barcodes_col)
head(glial_barcodes)
# Match the barcodes between the glial cells and expression matrix
matched_barcodes_idx <- match(glial_barcodes, barcodes_col_clean)
# Subset the expression matrix to include only the glial cells
subset_expression_matrix <- expression_matrix[, matched_barcodes_idx]
# Find the row corresponding to Ptgs1 in the features file
pts1_row <- grep("Ptgs1", features$V2, ignore.case = TRUE)
# Extract Ptgs1 expression for the glial cells
pts1_expression <- subset_expression_matrix[pts1_row, , drop = FALSE]
pts1_expression <- as.numeric(pts1_expression)
# Check if the number of glial cells matches the length of the expression vector
if (nrow(glial_cells) == length(pts1_expression)) {
glial_cells$Ptsg1_expression <- pts1_expression
} else {
stop("Mismatch between the number of glial cells and the length of Ptgs1 expression data.")
}
# Plot the Ptgs1 expression in glial cells
ggplot(glial_cells, aes(x = subclass_label, y = Ptsg1_expression)) +
geom_bar(stat = "identity", fill = "steelblue") +
theme_minimal() +
labs(title = "Ptgs1 Gene Expression in Glial Cells", x = "Cell Type", y = "Expression Level") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Change "Macrophage" to "Microglia/Macrophage" in the subclass_label column
glial_cells$subclass_label <- gsub("Macrophage", "Microglia/Macrophage", glial_cells$subclass_label)
# Reorder subclass_label factor levels to put Microglia/Macrophage first, Endo second, and Astro third
glial_cells$subclass_label <- factor(glial_cells$subclass_label,
levels = c("Microglia/Macrophage", "Endo", "Astro", "Oligo", "OPC"))
# Create the plot with the new order
ggplot(glial_cells, aes(x = subclass_label, y = Ptsg1_expression, fill = subclass_label)) +
geom_bar(stat = "identity") +
theme_minimal() + # Minimal theme to remove unnecessary background elements
theme(panel.grid = element_blank(), # Remove background grid lines
axis.line = element_line(), # Add axis lines
axis.text.x = element_text(angle = 45, hjust = 1)) + # Rotate x-axis labels
scale_fill_manual(values = c("Astro" = "gray", "Endo" = "magenta",
"Microglia/Macrophage" = "green3")) + # Change colors for specific categories
labs(title = "Ptgs1- Mus musculus",
x = "Cell Type",
y = "FPKM")

Project Name
This is your Project description. A brief summary can help visitors understand the context of your work. Click on "Edit Text" or double click on the text box to start.

Project Name
This is your Project description. Provide a brief summary to help visitors understand the context and background of your work. Click on "Edit Text" or double click on the text box to start.

Project Name
This is your Project description. Click on "Edit Text" or double click on the text box to start.

Project Name
This is your Project description. Provide a brief summary to help visitors understand the context and background of your work. Click on "Edit Text" or double click on the text box to start.

Project Name
This is your Project description. A brief summary can help visitors understand the context of your work. Click on "Edit Text" or double click on the text box to start.
