Add samples IDs to Seurat object when integrating different samples to do differential expression analysis
1
1
Entering edit mode
9 months ago
Sara ▴ 260

I have scRNAseq data and I am trying to do differential comparing 2 conditions (for each condition I have 3 samples). to do so I am using Seurat R package and to integrate the samples I used the following code. the part1 has code only for 1 sample (for other 5 samples I did the same) but the part2 is complete

part1:

med1 <- Read10X("AM-g001-raw-feature-bc-matrix")
med1 <- CreateSeuratObject(counts = med1, project = "med", min.cells = 3, min.features = 200)
med1 <- PercentageFeatureSet(med1, pattern = "^MT-", col.name = "percent.mt") 
med1 <- subset((med1, subset = nFeature_RNA < 4000 & nCount_RNA < 20000 & pecent.mt < 10 )

part2:

med_isa.list <- list(med1 = med1, med2 = med2, med3 = med3, iSA1 = iSA1, iSA2 = iSA2, iSA3 = iSA3)

med_isa.list <- lapply(x = med_isa.list, FUN = function(x) {
    x <- NormalizeData(x)
    x <- FindVariableFeatures(x, selection.method = "vst", nfeatures = 2000)
}) 
features <- SelectIntegrationFeatures(object.list = med_isa.list)
med_isa.anchores <- FindIntegrationAnchors(object.list = med_isa.list, anchor.features = features)
med_isa.combined <- IntegrateData(anchorset = med_isa.anchores)
DefaultAssay(med_isa.combined) <- "integrated"
med_isa.combined <- ScaleData(med_isa.combined, verbose = FALSE)
med_isa.combined <- RunPCA(med_isa.combined, npcs = 50, verbose = FALSE)
med_isa.combined <- RunUMAP(med_isa.combined, reduction = "pca", dims = 1:30)
med_isa.combined <- FindNeighbors(med_isa.combined, reduction = "pca", dims = 1:30)
med_isa.combined <- FindClusters(med_isa.combined, resolution = 0.6)
saveRDS(med_isa.combined, file="med_isa.combined.rds")

when I look at med_isa.combined I would expect to see samples IDs as well but it does not exist. I only see the following items:

  1. orig.ident: which is either med or isa
  2. seurat_clusters
  3. nCount_RNA
  4. nFeature_RNA
  5. percent.mt

How can I add another item to med_isa.combined which shows the sample IDs?

scRNA-seq Seurat • 847 views
ADD COMMENT
2
Entering edit mode
9 months ago
fracarb8 ★ 1.7k

When I integrate multiple samples together, I make sure to have, in each object :

  • a column of the metadata table (medX@meta.data$SampleID) with the sampleID
  • the sampleID at the beginning of each barcode (sample1_AAATGGTAGAGAT-1)

The first point allow you to easily group/split your integrated object, and the second point avoid any confusion/duplication of barcodes between samples.

In your case you don't see it because your project is "med" (project name is saved into orig.ident) for each sample. I would either

sample_name <- "med1"
CreateSeuratObject(counts = med1, project = sample_name,..

or simply med1@meta.data$SampleID <- "med1"

ADD COMMENT

Login before adding your answer.

Traffic: 1160 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