Is my code using Seurat correctly?
0
0
Entering edit mode
19 months ago

Hello,

My name is Shweta Johari and I have 4 datasets and I have run it on Seurat using the integration vignette.

My questions are as follows:

  1. Is the running of the code correct?
  2. Now that I have the clusters, what to do?
library(Seurat)
library(patchwork)

control = Read10X("C:/Users/TVIT1/Desktop/imtegrationsdj_Tuall/Tu1_099")
inhibitor = Read10X("C:/Users/TVIT1/Desktop/imtegrationsdj_Tuall/Tu2_099")
dnavaccine = Read10X("C:/Users/TVIT1/Desktop/imtegrationsdj_Tuall/Tu3_099")
combitr = Read10X("C:/Users/TVIT1/Desktop/imtegrationsdj_Tuall/Tu4_099")

# Created the Seurat Object:
control_seurat = CreateSeuratObject(counts = control$Gene Expression, project = "control")
inhibitor_seurat = CreateSeuratObject(counts = inhibitor$Gene Expression, project = "inhibitor")
dnavaccine_seurat = CreateSeuratObject(counts = dnavaccine$Gene Expression, project = "dnavaccine")
combitr_seurat = CreateSeuratObject(counts = combitr$Gene Expression, project = "combitr")

# Merged the datasets
merge_seurat = merge(x = control_seurat, y = c(inhibitor_seurat, dnavaccine_seurat, combitr_seurat), add.cell.id = c("control", "inhibitor","dnavaccine", "combitr"))
head(merge_seurat@meta.data,5)

# Filtering the mitochondrial genes
merge_seurat$mitoRatio <- PercentageFeatureSet(object = merge_seurat, pattern = "^mt-")
metadata <- merge_seurat@meta.data
metadata$cells <- rownames(metadata)
library(dplyr)
metadata <- metadata %>%
dplyr::rename(group = orig.ident,
nUMI = nCount_RNA,
nGene = nFeature_RNA)
library(stringr)
metadata$sample <- NA
metadata$sample[which(str_detect(metadata$cells, "^control_"))] <- "control"
metadata$sample[which(str_detect(metadata$cells, "^inhibitor_"))] <- "inhibitor"
metadata$sample[which(str_detect(metadata$cells, "^dnavaccine_"))] <- "dnavaccine"
metadata$sample[which(str_detect(metadata$cells, "^combitr_"))] <- "combitr"
merge_seurat@meta.data <- metadata
head(merge_seurat@meta.data,5)
tail(merge_seurat@meta.data,5)
data.list <- SplitObject(merge_seurat, split.by = "sample")

data.list <- lapply(X = data.list, FUN = function(x) {
x <- NormalizeData(x)
x <- FindVariableFeatures(x, selection.method = "vst")
})

# Integration of datasets
features <- SelectIntegrationFeatures(object.list = data.list)
immune.anchors <- FindIntegrationAnchors(object.list = data.list, anchor.features = features)
immune.combined <- IntegrateData(anchorset = immune.anchors)
DefaultAssay(immune.combined) <- "integrated"
immune.combined <- ScaleData(immune.combined, verbose = FALSE)
immune.combined <- RunPCA(immune.combined, npcs = 30, verbose = FALSE)
immune.combined <- RunUMAP(immune.combined, reduction = "pca", dims = 1:10)
immune.combined <- FindNeighbors(immune.combined, reduction = "pca", dims = 1:30)
immune.combined <- FindClusters(immune.combined, resolution = 0.5)
p1 <- DimPlot(immune.combined, reduction = "umap", group.by = "sample")
p2 <- DimPlot(immune.combined, reduction = "umap", label = TRUE, repel = TRUE)
DimPlot(immune.combined, reduction = "umap", split.by = "sample")

DefaultAssay(immune.combined) <- "RNA"
library(metap)
all.markers084 <- FindAllMarkers(immune.combined, only.pos = TRUE, min.pct = 0.25, logfc.threshold = 0.25)

sixteen.markers084 <- FindConservedMarkers(immune.combined, ident.1 = 16, grouping.var = "sample", verbose = FALSE)

Questions again:

  • Is this correct?
  • What next?
R Seurat • 513 views
ADD COMMENT
0
Entering edit mode

if you follow the vignette then there is a good chance that you do a reasonable analysis. For the "what to do" question, it helps to think about your analysis goal first. So what is the question you want to answer?

ADD REPLY

Login before adding your answer.

Traffic: 3237 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6