satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.26k stars 908 forks source link

Error when normalizing antibody capture (10X + dCODE dextramer data) #1835

Closed nilsrudqvist closed 5 years ago

nilsrudqvist commented 5 years ago

Hi,

First, thank you for creating Seurat!

Secondly, I am working to integrating multi-model single cell data from 4 different samples generated using the 10X platform. For each sample, I have made 3 libraries: i) 5'RNA, ii) dCODE dextramer (feature barcoding system), and iii) TCR sequencing.

I have been able to properly load and analyze the 5'RNA data but I run into an issue when trying to add the feature barcoding into the mix:

# Create Seurat object from RNA expression data
UT.data <- Read10X(data.dir = "../data/sc_rna_seq/Untreated/outs/filtered_feature_bc_matrix/")
UT <- CreateSeuratObject(counts = UT.data$`Gene Expression`, project = "A.Untreated")

# Add antibody capture data to the Seurat object
UT.data$`Antibody Capture`@Dimnames[[2]] <- 'AH1-dextramer' 
UT[["ADT"]] <- CreateAssayObject(counts = UT.data$`Antibody Capture` %>% t)

# Add information about mitochondrial gene content 
UT[["percent.mt"]] <- PercentageFeatureSet(UT, pattern = "^mt-")

# Visualize QC metrics
VlnPlot(UT, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3, pt.size = PT_SIZE)
CombinePlots(plots = list(FeatureScatter(UT, feature1 = "nCount_RNA", feature2 = "percent.mt", pt.size = PT_SIZE, span=T), 
                          FeatureScatter(UT, feature1 = "nCount_RNA", feature2 = "nFeature_RNA", pt.size = PT_SIZE, span=T)), ncol=2, legend = "none")

# Filter cells 
UT <- subset(UT, subset = nFeature_RNA > 200 & nFeature_RNA < 5000 & percent.mt < 5)

# Normalize data
UT <- NormalizeData(UT)
UT <- NormalizeData(UT, assay = "ADT", normalization.method = "CLR")

This works fine except for when trying to normalize my ADT assay:

Normalizing across features |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed = 00s Show Traceback Error in checkSlotAssignment(object, name, value) : assignment of an object of class numeric” is not valid for slot ‘data’ in an object of class “Assay”; is(value, "AnyMatrix") is not TRUE

I have tried to ignore normalizing the ADT assay for each of my 4 samples, but then when I try to integrate the data, I run into the same problem:

# Integrate datasets
immune.anchors <- FindIntegrationAnchors(object.list = list(UT, aCTLA4, RT, COMBO), assay = c("RNA","RNA","RNA","RNA"), dims = 1:20)

Error in checkSlotAssignment(object, name, value) : assignment of an object of class “numeric” is not valid for slot ‘data’ in an object of class “Assay”; is(value, "AnyMatrix") is not TRUE

I feel the error is probably easy fixed and related to my form of data somehow, but I have not been able to figure out a solution.

Please find the datafiles here if needed: https://www.dropbox.com/sh/lii9rjm0y8gmeyo/AACTV1_BxdTL0SSTx9jcB-nia?dl=1

Thank you in advance!

Best, Nils

yuhanH commented 5 years ago

Hi, For your first error, it results from the single protein value in your ADT counts. For the integration error, could you also attach part of your data?

nilsrudqvist commented 5 years ago

Hi, thank you so much for your response!

Hi, For your first error, it results from the single protein value in your ADT counts.

Ok, I understand this is the issue, but I assume I need to normalize/transform the ADT data for each Seurat-object BEFORE integrating?

For the integration error, could you also attach part of your data?

Please use this link to find a Rstudio project with data and code that you can use to replicate the error.

Again, thank you so much for helping me figuring out this error, and for creating such a useful package!

Best, Nils

yuhanH commented 5 years ago

Hi, Nils I cannot reproduce your integration error. I you update your seurat into the latest version, here For the ADT issue, I think you could just add one column with the same value. Then the normalization error is fixed.

adt_counts <-  GroupB.data$`Antibody Capture` %>% t
adt_counts <- rbind(adt_counts , adt_counts)
GroupB[["ADT"]] <- CreateAssayObject(counts = adt_counts)

Another issue in the code in your link, you should not run SCTransform on the integrated assay. SCTransform aims to eliminate sequencing noise, and it should be applied in the RNA assay. You can check this vignette for more detail information about SCTransform integration.

nilsrudqvist commented 5 years ago

Dear Yuhan,

Thank you so much for your help. I was able to normalize the ADT assay after duplicating the reads. It looks fine.

Regarding SCTransform I decided to go back to a more standardized workflow - I am not an advanced user of Seurat yet.

Performed a few sanity checks and it all looks pretty nice.

Thanks, Nils