Question: gene counts in Seurat after RunCCA() and AlignSubspace()
0
gravatar for Bogdan
2.1 years ago by
Bogdan1.1k
Palo Alto, CA, USA
Bogdan1.1k wrote:

Dear all,

happy and healthy new year !

I would appreciate your help on scRNA-seq analysis , as I am doing a comparison between 2 scRNA-seq datasets, and after I use RunCCA() and AlignSubspace(), as described here :

https://satijalab.org/seurat/immune_alignment.html

please would you let me know how I can access the matrices with the appropriate (processed) gene counts,

in order to make customized boxplots BETWEEN specific GENES that belong to distinct CLUSTERS in CONTROL vs TREATMENT1 (and TREATMENT2) ? thank you very much !

> str(both.combined)
Formal class 'seurat' [package "Seurat"] with 20 slots
  ..@ raw.data    :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. ..@ i       : int [1:10354214] 2 22 24 41 43 45 65 67 79 90 ...
  .. .. ..@ p       : int [1:3172] 0 1386 5184 7061 11913 13631 15513 17776 19993 21875 ...
  .. .. ..@ Dim     : int [1:2] 15213 3171
  .. .. ..@ Dimnames:List of 2
  .. .. .. ..$ : chr [1:15213] "Xkr4" "Rp1" "Mrpl15" "Lypla1" ...
  .. .. .. ..$ : chr [1:3171] "ctrl_AAACCTGAGGATTCGG" "ctrl_AAACCTGAGTACTTGC" "ctrl_AAACCTGCAGATAATG" "ctrl_AAACGGGAGACGCACA" ...
  .. .. ..@ x       : num [1:10354214] 3 2 2 15 1 3 1 2 1 1 ...
  .. .. ..@ factors : list()
  ..@ data        :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. ..@ i       : int [1:10354214] 2 22 24 41 43 45 65 67 79 90 ...
  .. .. ..@ p       : int [1:3172] 0 1386 5184 7061 11913 13631 15513 17776 19993 21875 ...
  .. .. ..@ Dim     : int [1:2] 15213 3171
  .. .. ..@ Dimnames:List of 2
  .. .. .. ..$ : chr [1:15213] "Xkr4" "Rp1" "Mrpl15" "Lypla1" ...
  .. .. .. ..$ : chr [1:3171] "ctrl_AAACCTGAGGATTCGG" "ctrl_AAACCTGAGTACTTGC" "ctrl_AAACCTGCAGATAATG" "ctrl_AAACGGGAGACGCACA" ...
  .. .. ..@ x       : num [1:10354214] 1.756 1.433 1.433 3.216 0.954 ...
  .. .. ..@ factors : list()
  ..@ scale.data  : num [1:15213, 1:3171] -0.0612 -0.0979 2.8866 -0.6214 -1.0193 ...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:15213] "Xkr4" "Rp1" "Mrpl15" "Lypla1" ...
  .. .. ..$ : chr [1:3171] "ctrl_AAACCTGAGGATTCGG" "ctrl_AAACCTGAGTACTTGC" "ctrl_AAACCTGCAGATAATG" "ctrl_AAACGGGAGACGCACA" ...
  ..@ var.genes   : chr [1:1157] "Sprr1a" "S100a6" "Spp1" "Cartpt" ...
  ..@ is.expr     : num 0
  ..@ ident       : Factor w/ 18 levels "c1_CTRL","c1_G11",..: 5 9 15 1 5 7 1 1 7 11 ...
  .. ..- attr(*, "names")= chr [1:3171] "ctrl_AAACCTGAGGATTCGG" "ctrl_AAACCTGAGTACTTGC" "ctrl_AAACCTGCAGATAATG" "ctrl_AAACGGGAGACGCACA" ...
  ..@ meta.data   :'data.frame':    3171 obs. of  7 variables:
  .. ..$ nGene        : int [1:3171] 1387 3799 1879 4856 1718 1884 2263 2218 1882 5230 ...
  .. ..$ nUMI         : num [1:3171] 6267 19298 5172 18883 11472 ...
  .. ..$ orig.ident   : Factor w/ 1 level "comparison.ctrl.vs.g11": 1 1 1 1 1 1 1 1 1 1 ...
  .. ..$ stim         : chr [1:3171] "CTRL" "CTRL" "CTRL" "CTRL" ...
  .. ..$ res.0.6      : chr [1:3171] "2" "4" "7" "0" ...
  .. ..$ celltype.stim: chr [1:3171] "c3_CTRL" "c5_CTRL" "c8_CTRL" "c1_CTRL" ...
  .. ..$ celltype     : chr [1:3171] "c3" "c5" "c8" "c1" ...
  ..@ project.name: chr "comparison.ctrl.vs.g11"
  ..@ dr          :List of 3
  .. ..$ cca        :Formal class 'dim.reduction' [package "Seurat"] with 7 slots
  .. .. .. ..@ cell.embeddings   : num [1:3171, 1:30] 0.0348 0.0264 0.0147 -0.0331 0.0375 ...
  .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. .. .. ..$ : chr [1:3171] "ctrl_AAACCTGAGGATTCGG" "ctrl_AAACCTGAGTACTTGC" "ctrl_AAACCTGCAGATAATG" "ctrl_AAACGGGAGACGCACA" ...
  .. .. .. .. .. ..$ : chr [1:30] "CC1" "CC2" "CC3" "CC4" ...
  .. .. .. ..@ gene.loadings     : num [1:1157, 1:30] 9.3 73.6 44.1 -23.2 -59.9 ...
  .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. .. .. ..$ : chr [1:1157] "Sprr1a" "S100a6" "Spp1" "Cartpt" ...
  .. .. .. .. .. ..$ : chr [1:30] "CC1" "CC2" "CC3" "CC4" ...
  .. .. .. ..@ gene.loadings.full: num [1:15213, 1:30] -2.73 -7.44 5.12 -9.41 -2.36 ...
  .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. .. .. ..$ : chr [1:15213] "Xkr4" "Rp1" "Mrpl15" "Lypla1" ...
  .. .. .. .. .. ..$ : chr [1:30] "CC1" "CC2" "CC3" "CC4" ...
  .. .. .. ..@ sdev              : num(0) 
  .. .. .. ..@ key               : chr "CC"
  .. .. .. ..@ jackstraw         : NULL
  .. .. .. ..@ misc              : NULL
  .. ..$ cca.aligned:Formal class 'dim.reduction' [package "Seurat"] with 7 slots
  .. .. .. ..@ cell.embeddings   : num [1:3171, 1:20] 1.421 1.058 0.551 -1.527 1.542 ...
  .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. .. .. ..$ : chr [1:3171] "ctrl_AAACCTGAGGATTCGG" "ctrl_AAACCTGAGTACTTGC" "ctrl_AAACCTGCAGATAATG" "ctrl_AAACGGGAGACGCACA" ...
  .. .. .. .. .. ..$ : chr [1:20] "ACC1" "ACC2" "ACC3" "ACC4" ...
  .. .. .. ..@ gene.loadings     : num[0 , 0 ] 
  .. .. .. ..@ gene.loadings.full: num[0 , 0 ] 
  .. .. .. ..@ sdev              : num(0) 
  .. .. .. ..@ key               : chr "ACC"
  .. .. .. ..@ jackstraw         : NULL
  .. .. .. ..@ misc              : NULL
  .. ..$ tsne       :Formal class 'dim.reduction' [package "Seurat"] with 7 slots
  .. .. .. ..@ cell.embeddings   : num [1:3171, 1:2] -33.16 -10.77 -5.71 26.2 -33.57 ...
  .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. .. .. ..$ : chr [1:3171] "ctrl_AAACCTGAGGATTCGG" "ctrl_AAACCTGAGTACTTGC" "ctrl_AAACCTGCAGATAATG" "ctrl_AAACGGGAGACGCACA" ...
  .. .. .. .. .. ..$ : chr [1:2] "tSNE_1" "tSNE_2"
  .. .. .. ..@ gene.loadings     : num[0 , 0 ] 
  .. .. .. ..@ gene.loadings.full: num[0 , 0 ] 
  .. .. .. ..@ sdev              : num(0) 
  .. .. .. ..@ key               : chr "tSNE_"
  .. .. .. ..@ jackstraw         : NULL
  .. .. .. ..@ misc              : NULL
  ..@ assay       : list()
  ..@ hvg.info    :'data.frame':    0 obs. of  0 variables
Formal class 'data.frame' [package "methods"] with 4 slots
  .. .. ..@ .Data    : list()
  .. .. ..@ names    : chr(0) 
  .. .. ..@ row.names: int(0) 
  .. .. ..@ .S3Class : chr "data.frame"
  ..@ imputed     :'data.frame':    0 obs. of  0 variables
Formal class 'data.frame' [package "methods"] with 4 slots
  .. .. ..@ .Data    : list()
  .. .. ..@ names    : chr(0) 
  .. .. ..@ row.names: int(0) 
  .. .. ..@ .S3Class : chr "data.frame"
  ..@ cell.names  : chr [1:3171] "ctrl_AAACCTGAGGATTCGG" "ctrl_AAACCTGAGTACTTGC" "ctrl_AAACCTGCAGATAATG" "ctrl_AAACGGGAGACGCACA" ...
  ..@ cluster.tree: list()
  ..@ snn         :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. ..@ i       : int 0
  .. .. ..@ p       : int [1:2] 0 1
  .. .. ..@ Dim     : int [1:2] 1 1
  .. .. ..@ Dimnames:List of 2
  .. .. .. ..$ : NULL
  .. .. .. ..$ : NULL
  .. .. ..@ x       : num 1
  .. .. ..@ factors : list()
  ..@ calc.params :List of 7
  .. ..$ CreateSeuratObject  :List of 13
  .. .. ..$ project             : chr "comparison.ctrl.vs.g11"
  .. .. ..$ min.cells           : num 0
  .. .. ..$ min.genes           : num 0
  .. .. ..$ is.expr             : num 0
  .. .. ..$ normalization.method: NULL
  .. .. ..$ scale.factor        : num 10000
  .. .. ..$ do.scale            : logi FALSE
  .. .. ..$ do.center           : logi FALSE
  .. .. ..$ names.field         : num 1
  .. .. ..$ names.delim         : chr "_"
  .. .. ..$ display.progress    : logi TRUE
  .. .. ..$ ...                 : symbol 
  .. .. ..$ time                : POSIXct[1:1], format: "2019-01-05 18:33:46"
  .. ..$ NormalizeData       :List of 5
  .. .. ..$ assay.type          : chr "RNA"
  .. .. ..$ normalization.method: chr "LogNormalize"
  .. .. ..$ scale.factor        : num 10000
  .. .. ..$ display.progress    : logi TRUE
  .. .. ..$ time                : POSIXct[1:1], format: "2019-01-05 18:33:46"
  .. ..$ ScaleData           :List of 16
  .. .. ..$ genes.use         : chr [1:15213] "Xkr4" "Rp1" "Mrpl15" "Lypla1" ...
  .. .. ..$ vars.to.regress   : symbol 
  .. .. ..$ model.use         : chr "linear"
  .. .. ..$ use.umi           : logi FALSE
  .. .. ..$ do.scale          : logi TRUE
  .. .. ..$ do.center         : logi TRUE
  .. .. ..$ scale.max         : num 10
  .. .. ..$ block.size        : num 1000
  .. .. ..$ min.cells.to.block: num 3000
  .. .. ..$ display.progress  : logi TRUE
  .. .. ..$ assay.type        : chr "RNA"
  .. .. ..$ do.cpp            : logi TRUE
  .. .. ..$ check.for.norm    : logi TRUE
  .. .. ..$ do.par            : logi FALSE
  .. .. ..$ num.cores         : num 1
  .. .. ..$ time              : POSIXct[1:1], format: "2019-01-05 18:33:47"
  .. ..$ RunCCA              :List of 11
  .. .. ..$ group1         : symbol 
  .. .. ..$ group2         : symbol 
  .. .. ..$ group.by       : symbol 
  .. .. ..$ num.cc         : num 30
  .. .. ..$ genes.use      : chr [1:1157] "Sprr1a" "S100a6" "Spp1" "Cartpt" ...
  .. .. ..$ scale.data     : logi TRUE
  .. .. ..$ rescale.groups : logi FALSE
  .. .. ..$ ...            :length 2, mode "...": "ctrl" "stim"
  .. .. ..$ time           : POSIXct[1:1], format: "2019-01-05 18:33:53"
  .. .. ..$ object.project : chr "comparison.ctrl.vs.g11"
  .. .. ..$ object2.project: chr "comparison.ctrl.vs.g11"
  .. ..$ AlignSubspace.cca   :List of 9
  .. .. ..$ reduction.type    : chr "cca"
  .. .. ..$ grouping.var      : chr "stim"
  .. .. ..$ dims.align        : int [1:20] 1 2 3 4 5 6 7 8 9 10 ...
  .. .. ..$ num.possible.genes: num 2000
  .. .. ..$ num.genes         : num 30
  .. .. ..$ show.plots        : logi FALSE
  .. .. ..$ verbose           : logi TRUE
  .. .. ..$ ...               : symbol 
  .. .. ..$ time              : POSIXct[1:1], format: "2019-01-05 18:35:41"
  .. ..$ RunTSNE             :List of 13
  .. .. ..$ reduction.use  : chr "cca.aligned"
  .. .. ..$ cells.use      : NULL
  .. .. ..$ dims.use       : int [1:20] 1 2 3 4 5 6 7 8 9 10 ...
  .. .. ..$ genes.use      : NULL
  .. .. ..$ seed.use       : num 1
  .. .. ..$ tsne.method    : chr "Rtsne"
  .. .. ..$ add.iter       : num 0
  .. .. ..$ dim.embed      : num 2
  .. .. ..$ distance.matrix: NULL
  .. .. ..$ reduction.name : chr "tsne"
  .. .. ..$ reduction.key  : chr "tSNE_"
  .. .. ..$ ...            :length 1, mode "...": TRUE
  .. .. ..$ time           : POSIXct[1:1], format: "2019-01-05 18:37:25"
  .. ..$ FindClusters.res.0.6:List of 21
  .. .. ..$ genes.use         : NULL
  .. .. ..$ reduction.type    : chr "cca.aligned"
  .. .. ..$ dims.use          : int [1:20] 1 2 3 4 5 6 7 8 9 10 ...
  .. .. ..$ k.param           : num 30
  .. .. ..$ plot.SNN          : logi FALSE
  .. .. ..$ prune.SNN         : num 0.0667
  .. .. ..$ print.output      : logi TRUE
  .. .. ..$ distance.matrix   : NULL
  .. .. ..$ save.SNN          : logi FALSE
  .. .. ..$ reuse.SNN         : logi FALSE
  .. .. ..$ force.recalc      : logi FALSE
  .. .. ..$ nn.eps            : num 0
  .. .. ..$ modularity.fxn    : num 1
  .. .. ..$ resolution        : num 0.6
  .. .. ..$ algorithm         : num 1
  .. .. ..$ n.start           : num 100
  .. .. ..$ n.iter            : num 10
  .. .. ..$ random.seed       : num 0
  .. .. ..$ temp.file.location: NULL
  .. .. ..$ edge.file.name    : NULL
  .. .. ..$ time              : POSIXct[1:1], format: "2019-01-05 18:37:25"
  ..@ kmeans      : NULL
  ..@ spatial     :Formal class 'spatial.info' [package "Seurat"] with 4 slots
  .. .. ..@ mix.probs    :'data.frame': 3171 obs. of  1 variable:
  .. .. .. ..$ nGene: int [1:3171] 1386 3798 1877 4852 1718 1882 2263 2217 1882 5222 ...
  .. .. ..@ mix.param    :'data.frame': 0 obs. of  0 variables
Formal class 'data.frame' [package "methods"] with 4 slots
  .. .. .. .. ..@ .Data    : list()
  .. .. .. .. ..@ names    : chr(0) 
  .. .. .. .. ..@ row.names: int(0) 
  .. .. .. .. ..@ .S3Class : chr "data.frame"
  .. .. ..@ final.prob   :'data.frame': 0 obs. of  0 variables
Formal class 'data.frame' [package "methods"] with 4 slots
  .. .. .. .. ..@ .Data    : list()
  .. .. .. .. ..@ names    : chr(0) 
  .. .. .. .. ..@ row.names: int(0) 
  .. .. .. .. ..@ .S3Class : chr "data.frame"
  .. .. ..@ insitu.matrix:'data.frame': 0 obs. of  0 variables
Formal class 'data.frame' [package "methods"] with 4 slots
  .. .. .. .. ..@ .Data    : list()
  .. .. .. .. ..@ names    : chr(0) 
  .. .. .. .. ..@ row.names: int(0) 
  .. .. .. .. ..@ .S3Class : chr "data.frame"
  ..@ misc        : NULL
  ..@ version     :Classes 'package_version', 'numeric_version'  hidden list of 1
  .. ..$ : int [1:3] 2 3 4
cca seurat scrna-seq • 1.7k views
ADD COMMENTlink modified 2.0 years ago • written 2.1 years ago by Bogdan1.1k

In the continuation of my previous message, if I may rephrase the question above; I would appreciate having your insights :)

After following the tutorial that is available at : https://satijalab.org/seurat/immune_alignment.html, the questions are :

1 -- after running " immune.combined <- RunCCA(ctrl, stim, genes.use = genes.use, num.cc = 30)"

in @data and @scale.data, we have the normalized data and the scaled data of the samples as available in the objects "ctrl.data", and "stim.data", correct ? Or these data were modified by CCA algorithm ?

2 -- I could see that the command :

"immune.combined <- AlignSubspace(immune.combined, reduction.type = "cca", grouping.var = "stim", dims.align = 1:20)"

changes only the @scale.data. and not the normalized values in @data : is this expected ?

in which slot could i find the corrected/CCA-aligned "normalized data" of those 2 samples ?

thanks a lot !

ADD REPLYlink written 2.0 years ago by Bogdan1.1k
1
gravatar for Avi
2.0 years ago by
Avi70
United States
Avi70 wrote:

Had a similar question before and raised an issue here, https://github.com/satijalab/seurat/issues/283 Hope it helps.

ADD COMMENTlink modified 2.0 years ago • written 2.0 years ago by Avi70

Thanks a lot, Avi. Yes, it is very helpful indeed.

After extracting the NORM.DATA and SCALE.DATA for a few cells in the original matrix, and comparing the expression values at different steps in the algorithm :

-- indeed I have not seen any changes in the numerical values in @DATA (there is no batch-correction)

-- the expression values in the @SCALE.DATA change after runCCA() for some cells ...

ADD REPLYlink modified 2.0 years ago • written 2.0 years ago by Bogdan1.1k
0
gravatar for igor
2.0 years ago by
igor12k
United States
igor12k wrote:

There are no "corrected" counts after CCA. CCA is used as an alternate dimensionality reduction. Your Seurat object now has cca and cca.aligned in the dr slot. You can think of it as PCA. After you run PCA, your counts matrix is still the same, but you now have an additional PC matrix.

ADD COMMENTlink modified 2.0 years ago • written 2.0 years ago by igor12k

Thank you Igor .. oh well, as I am not a statistician, my thought was that AlignSubspace() function provides also "corrected" counts, as mnnCorrect() or Combat() would do.

however, I can see that RunCCA() change the expression values in the @scale.data for some cells : if I may ask, how does it do it ? thanks a lot !

ADD REPLYlink modified 2.0 years ago • written 2.0 years ago by Bogdan1.1k

The CCA process removes a small fraction of cells. Then, the new matrix is re-scaled. Thus, the values may change.

ADD REPLYlink written 2.0 years ago by igor12k

Thank you, Igor. If I may add please a follow up question : for batch correction in scRNA-seq (when comparing multiple cell treatments), which algorithm would you recommend ? mnnCorrect() in SCRAN, combat() in SVA, or any other algorithm ? thanks a lot !

ADD REPLYlink written 2.0 years ago by Bogdan1.1k
0
gravatar for Bogdan
2.0 years ago by
Bogdan1.1k
Palo Alto, CA, USA
Bogdan1.1k wrote:

Thanks a lot, Avi. Yes, it is very helpful indeed.

After extracting the NORM.DATA and SCALE.DATA for a few cells in the original matrix, and comparing the expression values at different steps in the algorithm :

-- indeed I have not seen any changes in the numerical values in @DATA (there is no batch-correction)

-- the expression values in the @SCALE.DATA change only after runCCA() for some cells ..

ADD COMMENTlink modified 2.0 years ago • written 2.0 years ago by Bogdan1.1k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1551 users visited in the last hour
_