Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining counts of 2 genes into 1 gene - spatial #8914

Closed
LukeJ89 opened this issue May 20, 2024 · 1 comment
Closed

Combining counts of 2 genes into 1 gene - spatial #8914

LukeJ89 opened this issue May 20, 2024 · 1 comment

Comments

@LukeJ89
Copy link

LukeJ89 commented May 20, 2024

Hi,
I have some spatial data (Visium) that I have merged and am comparing gene expression between two inflammatory conditions. There is a particular gene that is significantly expressed in one of the conditions that I am interested in, let's call it Gene1. However, there is another gene that codes for the exact same protein, call it Gene1B, and this is significantly expressed in a the other condition, although not as greatly, which could impact the overall differential expression for that protein.
I was wondering if it were possible to combine the counts of Gene1 and Gene1B to make a new count called GF1, and run DGE analysis as this will give me a better understanding of the gene expression level for that one protein?

`

KP001B_spatial <-Load10X_Spatial("Z:/Spatial_Transcriptomics/KP001/KP001_B/outs/",
filename = "filtered_feature_bc_matrix.h5",
assay = "Spatial",
slice = "KP001B",
filter.matrix = TRUE,
to.upper = FALSE)

AD1_spatial <-Load10X_Spatial("Z:/Spatial_Transcriptomics/AD/AD_1/outs/",
filename = "filtered_feature_bc_matrix.h5",
assay = "Spatial",
slice = "AD_1",
filter.matrix = TRUE,
to.upper = FALSE)

Healthy1_spatial <-Load10X_Spatial("Z:/Spatial_Transcriptomics/Healthy/H_1/outs/",
filename = "filtered_feature_bc_matrix.h5",
assay = "Spatial",
slice = "H_1",
filter.matrix = TRUE,
to.upper = FALSE)

All_skin <- c(KP001B_spatial, AD1_spatial, Healthy1_spatial)
merged.data <- merge(x = All_skin[[1]], y = All_skin[-1], merge.data = T)
merged.data <- SCTransform(merged.data, assay = "Spatial", vars.to.regress = "sample.id")
merged.data <- RunPCA(merged.data, assay = "SCT")
merged.data.hm <- RunHarmony(merged.data, assay.use = "SCT", project.dim = F, group.by.vars = "sample.id")
merged.data.hm <- merged.data.hm %>%
RunUMAP(reduction = "harmony", dims = 1:40) %>%
FindNeighbors(reduction = "harmony", dims = 1:40) %>%
FindClusters(resolution = c(0.4, 0.5, 0.6, 0.7)) %>%
identity()
Idents(merged.data.hm ) <- 'SCT_snn_res.0.5'`

@LukeJ89 LukeJ89 changed the title Combining counts of 2 genes as into 1 gene - spatial Combining counts of 2 genes into 1 gene - spatial May 20, 2024
@dcollins15
Copy link
Contributor

The easiest way to do this is probably to read in the counts matrices via Read10X_h5, sum the relevant columns in the matrices, instantiate a Seurat object using CreateSeuratObject and then add the images in manually after reading them in via Read10X_Image - something along the lines of:

counts <- Read10X_h5("Z:/Spatial_Transcriptomics/KP001/KP001_B/outs/filtered_feature_bc_matrix.h5")
counts_GF1 <- counts["Gene1", ] + counts["Gene1B", ]
counts <- rbind(counts, GF1 = counts_GF1)
counts <- counts[!rownames(counts) %in% c("Gene1", "Gene1B"), ]

KP001B_spatial <- CreateSeuratObject(counts, assay = "Spatial")

image <- Read10X_Image(
  "Z:/Spatial_Transcriptomics/KP001/KP001_B/outs/spatial",
  assay = "Spatial",
  slice = "KP001B",
  filter.matrix = TRUE
)

image <- image[Cells(KP001B_spatial)]
KP001B_spatial[["KP001B"]] <- image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants