satijalab / seurat

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

Extract counts matrix from Seurat object #8781

Closed zgb963 closed 7 months ago

zgb963 commented 7 months ago

Hi Seurat team,

How can I extract the full counts matrix from a seurat object (with rows as features/genes and columns as cell barcodes). My seurat object is below.

str(seurat.obj_combined_filtered)

Formal class 'Seurat' [package "SeuratObject"] with 13 slots
  ..@ assays      :List of 1
  .. ..$ RNA:Formal class 'Assay5' [package "SeuratObject"] with 8 slots
  .. .. .. ..@ layers    :List of 3
  .. .. .. .. ..$ counts    :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. .. .. .. ..@ i       : int [1:132459583] 2 45 53 67 85 86 106 120 125 140 ...
  .. .. .. .. .. .. ..@ p       : int [1:56021] 0 1348 2347 3977 4975 6372 8075 9627 12038 14101 ...
  .. .. .. .. .. .. ..@ Dim     : int [1:2] 31405 56020
  .. .. .. .. .. .. ..@ Dimnames:List of 2
  .. .. .. .. .. .. .. ..$ : NULL
  .. .. .. .. .. .. .. ..$ : NULL
  .. .. .. .. .. .. ..@ x       : num [1:132459583] 1 1 2 1 3 4 8 6 1 3 ...
  .. .. .. .. .. .. ..@ factors : list()
  .. .. .. .. ..$ data      :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. .. .. .. ..@ i       : int [1:132459583] 2 45 53 67 85 86 106 120 125 140 ...
  .. .. .. .. .. .. ..@ p       : int [1:56021] 0 1348 2347 3977 4975 6372 8075 9627 12038 14101 ...
  .. .. .. .. .. .. ..@ Dim     : int [1:2] 31405 56020
  .. .. .. .. .. .. ..@ Dimnames:List of 2
  .. .. .. .. .. .. .. ..$ : NULL
  .. .. .. .. .. .. .. ..$ : NULL
  .. .. .. .. .. .. ..@ x       : num [1:132459583] 1.74 1.74 2.34 1.74 2.71 ...
  .. .. .. .. .. .. ..@ factors : list()
  .. .. .. .. ..$ scale.data: num [1:2000, 1:56020] -0.0109 -0.3257 -0.4102 -0.328 -0.1942 ...
  .. .. .. ..@ cells     :Formal class 'LogMap' [package "SeuratObject"] with 1 slot
  .. .. .. .. .. ..@ .Data: logi [1:56020, 1:3] TRUE TRUE TRUE TRUE TRUE TRUE ...
  .. .. .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. .. .. .. .. ..$ : chr [1:56020] "3_C_MI2_S1_AAACCCAAGCTAGATA-1" "3_C_MI2_S1_AAACCCAAGCTCACTA-1" "3_C_MI2_S1_AAACCCACAACAAGAT-1" "3_C_MI2_S1_AAACCCAGTCGGTAAG-1" ...
  .. .. .. .. .. .. .. ..$ : chr [1:3] "counts" "data" "scale.data"
  .. .. .. .. .. ..$ dim     : int [1:2] 56020 3
  .. .. .. .. .. ..$ dimnames:List of 2
  .. .. .. .. .. .. ..$ : chr [1:56020] "3_C_MI2_S1_AAACCCAAGCTAGATA-1" "3_C_MI2_S1_AAACCCAAGCTCACTA-1" "3_C_MI2_S1_AAACCCACAACAAGAT-1" "3_C_MI2_S1_AAACCCAGTCGGTAAG-1" ...
  .. .. .. .. .. .. ..$ : chr [1:3] "counts" "data" "scale.data"
  .. .. .. ..@ features  :Formal class 'LogMap' [package "SeuratObject"] with 1 slot
  .. .. .. .. .. ..@ .Data: logi [1:31405, 1:3] TRUE TRUE TRUE TRUE TRUE TRUE ...
  .. .. .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. .. .. .. .. ..$ : chr [1:31405] "PGBD2" "TRL-CAA4-1" "ZNF692" "ZNF672" ...
  .. .. .. .. .. .. .. ..$ : chr [1:3] "counts" "data" "scale.data"
  .. .. .. .. .. ..$ dim     : int [1:2] 31405 3
  .. .. .. .. .. ..$ dimnames:List of 2
  .. .. .. .. .. .. ..$ : chr [1:31405] "PGBD2" "TRL-CAA4-1" "ZNF692" "ZNF672" ...
  .. .. .. .. .. .. ..$ : chr [1:3] "counts" "data" "scale.data"
  .. .. .. ..@ default   : int 1
  .. .. .. ..@ assay.orig: chr(0) 
  .. .. .. ..@ meta.data :'data.frame': 31405 obs. of  8 variables:
  .. .. .. .. ..$ vf_vst_counts_mean                 : num [1:31405] 0.03754 0.000196 0.083702 0.033577 0.058086 ...
  .. .. .. .. ..$ vf_vst_counts_variance             : num [1:31405] 0.039488 0.000196 0.089657 0.033986 0.059962 ...
  .. .. .. .. ..$ vf_vst_counts_variance.expected    : num [1:31405] 0.042 0.0002 0.0962 0.0375 0.0657 ...
  .. .. .. .. ..$ vf_vst_counts_variance.standardized: num [1:31405] 0.94 0.983 0.932 0.907 0.913 ...
  .. .. .. .. ..$ vf_vst_counts_variable             : logi [1:31405] FALSE FALSE FALSE FALSE FALSE FALSE ...
  .. .. .. .. ..$ vf_vst_counts_rank                 : int [1:31405] NA NA NA NA NA NA NA NA NA NA ...
  .. .. .. .. ..$ var.features                       : chr [1:31405] NA NA NA NA ...
  .. .. .. .. ..$ var.features.rank                  : int [1:31405] NA NA NA NA NA NA NA NA NA NA ...
  .. .. .. ..@ misc      : Named list()
  .. .. .. ..@ key       : chr "rna_"
  ..@ meta.data   :'data.frame':    56020 obs. of  10 variables:
  .. ..$ orig.ident     : Factor w/ 6 levels "1","2","3","4",..: 3 3 3 3 3 3 3 3 3 3 ...
  .. ..$ nCount_RNA     : num [1:56020] 2133 1443 3058 1513 2238 ...
  .. ..$ nFeature_RNA   : int [1:56020] 1348 999 1630 998 1397 1703 1552 2411 2063 2757 ...
  .. ..$ RNA_snn_res.0.1: Factor w/ 16 levels "0","1","2","3",..: 2 3 10 11 2 2 1 4 1 1 ...
  .. ..$ RNA_snn_res.0.2: Factor w/ 18 levels "0","1","2","3",..: 2 3 12 13 6 6 1 5 1 1 ...
  .. ..$ RNA_snn_res.0.3: Factor w/ 20 levels "0","1","2","3",..: 2 3 12 13 6 6 1 5 1 1 ...
  .. ..$ RNA_snn_res.0.4: Factor w/ 22 levels "0","1","2","3",..: 1 3 13 14 5 5 2 7 6 6 ...
  .. ..$ seurat_clusters: Factor w/ 32 levels "0","1","2","3",..: 1 2 23 16 8 8 5 7 5 15 ...
  .. ..$ RNA_snn_res.0.6: Factor w/ 28 levels "0","1","2","3",..: 1 2 21 15 5 5 7 8 7 6 ...
  .. ..$ RNA_snn_res.0.8: Factor w/ 32 levels "0","1","2","3",..: 1 2 23 16 8 8 5 7 5 15 ...
  ..@ active.assay: chr "RNA"
  ..@ active.ident: Factor w/ 22 levels "0","1","2","3",..: 1 3 13 14 5 5 2 7 6 6 ...
  .. ..- attr(*, "names")= chr [1:56020] "3_C_MI2_S1_AAACCCAAGCTAGATA-1" "3_C_MI2_S1_AAACCCAAGCTCACTA-1" "3_C_MI2_S1_AAACCCACAACAAGAT-1" "3_C_MI2_S1_AAACCCAGTCGGTAAG-1" ...
  ..@ graphs      :List of 2
  .. ..$ RNA_nn :Formal class 'Graph' [package "SeuratObject"] with 7 slots
  .. .. .. ..@ assay.used: chr "RNA"
  .. .. .. ..@ i         : int [1:1120400] 0 8683 26455 33854 47982 1 22363 22475 33455 2 ...
  .. .. .. ..@ p         : int [1:56021] 0 5 9 45 62 68 90 130 141 155 ...
  .. .. .. ..@ Dim       : int [1:2] 56020 56020
  .. .. .. ..@ Dimnames  :List of 2
  .. .. .. .. ..$ : chr [1:56020] "3_C_MI2_S1_AAACCCAAGCTAGATA-1" "3_C_MI2_S1_AAACCCAAGCTCACTA-1" "3_C_MI2_S1_AAACCCACAACAAGAT-1" "3_C_MI2_S1_AAACCCAGTCGGTAAG-1" ...
  .. .. .. .. ..$ : chr [1:56020] "3_C_MI2_S1_AAACCCAAGCTAGATA-1" "3_C_MI2_S1_AAACCCAAGCTCACTA-1" "3_C_MI2_S1_AAACCCACAACAAGAT-1" "3_C_MI2_S1_AAACCCAGTCGGTAAG-1" ...
  .. .. .. ..@ x         : num [1:1120400] 1 1 1 1 1 1 1 1 1 1 ...
  .. .. .. ..@ factors   : list()
  .. ..$ RNA_snn:Formal class 'Graph' [package "SeuratObject"] with 7 slots
  .. .. .. ..@ assay.used: chr "RNA"
  .. .. .. ..@ i         : int [1:4101302] 0 816 5001 5128 6234 7930 8683 10883 12170 12388 ...
  .. .. .. ..@ p         : int [1:56021] 0 42 95 155 255 320 399 488 547 633 ...
  .. .. .. ..@ Dim       : int [1:2] 56020 56020
  .. .. .. ..@ Dimnames  :List of 2
  .. .. .. .. ..$ : chr [1:56020] "3_C_MI2_S1_AAACCCAAGCTAGATA-1" "3_C_MI2_S1_AAACCCAAGCTCACTA-1" "3_C_MI2_S1_AAACCCACAACAAGAT-1" "3_C_MI2_S1_AAACCCAGTCGGTAAG-1" ...
  .. .. .. .. ..$ : chr [1:56020] "3_C_MI2_S1_AAACCCAAGCTAGATA-1" "3_C_MI2_S1_AAACCCAAGCTCACTA-1" "3_C_MI2_S1_AAACCCACAACAAGAT-1" "3_C_MI2_S1_AAACCCAGTCGGTAAG-1" ...
  .. .. .. ..@ x         : num [1:4101302] 1 0.1111 0.0811 0.1111 0.0811 ...
  .. .. .. ..@ factors   : list()
  ..@ neighbors   : list()
  ..@ reductions  :List of 2
  .. ..$ pca :Formal class 'DimReduc' [package "SeuratObject"] with 9 slots
  .. .. .. ..@ cell.embeddings           : num [1:56020, 1:50] 2.8022 -20.2638 -0.0172 -8.8825 1.7871 ...
  .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. .. .. ..$ : chr [1:56020] "3_C_MI2_S1_AAACCCAAGCTAGATA-1" "3_C_MI2_S1_AAACCCAAGCTCACTA-1" "3_C_MI2_S1_AAACCCACAACAAGAT-1" "3_C_MI2_S1_AAACCCAGTCGGTAAG-1" ...
  .. .. .. .. .. ..$ : chr [1:50] "PC_1" "PC_2" "PC_3" "PC_4" ...
  .. .. .. ..@ feature.loadings          : num [1:2000, 1:50] -3.35e-02 3.15e-05 -9.14e-03 -5.00e-02 -6.08e-02 ...
  .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. .. .. ..$ : chr [1:2000] "SLC1A2" "GRIK1" "ADARB2" "RELN" ...
  .. .. .. .. .. ..$ : chr [1:50] "PC_1" "PC_2" "PC_3" "PC_4" ...
  .. .. .. ..@ feature.loadings.projected: num[0 , 0 ] 
  .. .. .. ..@ assay.used                : chr "RNA"
  .. .. .. ..@ global                    : logi FALSE
  .. .. .. ..@ stdev                     : num [1:50] 9.4 7.37 6.87 6.42 5.18 ...
  .. .. .. ..@ jackstraw                 :Formal class 'JackStrawData' [package "SeuratObject"] with 4 slots
  .. .. .. .. .. ..@ empirical.p.values     : num[0 , 0 ] 
  .. .. .. .. .. ..@ fake.reduction.scores  : num[0 , 0 ] 
  .. .. .. .. .. ..@ empirical.p.values.full: num[0 , 0 ] 
  .. .. .. .. .. ..@ overall.p.values       : num[0 , 0 ] 
  .. .. .. ..@ misc                      :List of 1
  .. .. .. .. ..$ total.variance: num 1579
  .. .. .. ..@ key                       : chr "PC_"
  .. ..$ umap:Formal class 'DimReduc' [package "SeuratObject"] with 9 slots
  .. .. .. ..@ cell.embeddings           : num [1:56020, 1:2] -4.029 -10.405 0.251 -6.301 -3.611 ...
  .. .. .. .. ..- attr(*, "scaled:center")= num [1:2] 0.279 0.093
  .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. .. .. ..$ : chr [1:56020] "3_C_MI2_S1_AAACCCAAGCTAGATA-1" "3_C_MI2_S1_AAACCCAAGCTCACTA-1" "3_C_MI2_S1_AAACCCACAACAAGAT-1" "3_C_MI2_S1_AAACCCAGTCGGTAAG-1" ...
  .. .. .. .. .. ..$ : chr [1:2] "umap_1" "umap_2"
  .. .. .. ..@ feature.loadings          : num[0 , 0 ] 
  .. .. .. ..@ feature.loadings.projected: num[0 , 0 ] 
  .. .. .. ..@ assay.used                : chr "RNA"
  .. .. .. ..@ global                    : logi TRUE
  .. .. .. ..@ stdev                     : num(0) 
  .. .. .. ..@ jackstraw                 :Formal class 'JackStrawData' [package "SeuratObject"] with 4 slots
  .. .. .. .. .. ..@ empirical.p.values     : num[0 , 0 ] 
  .. .. .. .. .. ..@ fake.reduction.scores  : num[0 , 0 ] 
  .. .. .. .. .. ..@ empirical.p.values.full: num[0 , 0 ] 
  .. .. .. .. .. ..@ overall.p.values       : num[0 , 0 ] 
  .. .. .. ..@ misc                      : list()
  .. .. .. ..@ key                       : chr "umap_"
  ..@ images      : list()
  ..@ project.name: chr "combined_rhemac10_snRNAseq_2024"
  ..@ misc        : list()
  ..@ version     :Classes 'package_version', 'numeric_version'  hidden list of 1
  .. ..$ : int [1:3] 5 0 1
  ..@ commands    :List of 7
  .. ..$ NormalizeData.RNA       :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. .. .. ..@ name       : chr "NormalizeData.RNA"
  .. .. .. ..@ time.stamp : POSIXct[1:1], format: "2024-03-18 19:36:47"
  .. .. .. ..@ assay.used : chr "RNA"
  .. .. .. ..@ call.string: chr "NormalizeData(seurat.obj_combined_filtered)"
  .. .. .. ..@ params     :List of 5
  .. .. .. .. ..$ assay               : chr "RNA"
  .. .. .. .. ..$ normalization.method: chr "LogNormalize"
  .. .. .. .. ..$ scale.factor        : num 10000
  .. .. .. .. ..$ margin              : num 1
  .. .. .. .. ..$ verbose             : logi TRUE
  .. ..$ FindVariableFeatures.RNA:Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. .. .. ..@ name       : chr "FindVariableFeatures.RNA"
  .. .. .. ..@ time.stamp : POSIXct[1:1], format: "2024-03-18 19:36:57"
  .. .. .. ..@ assay.used : chr "RNA"
  .. .. .. ..@ call.string: chr "FindVariableFeatures(seurat.obj_combined_filtered)"
  .. .. .. ..@ params     :List of 12
  .. .. .. .. ..$ assay              : chr "RNA"
  .. .. .. .. ..$ selection.method   : chr "vst"
  .. .. .. .. ..$ loess.span         : num 0.3
  .. .. .. .. ..$ clip.max           : chr "auto"
  .. .. .. .. ..$ mean.function      :function (mat, display_progress)  
  .. .. .. .. ..$ dispersion.function:function (mat, display_progress)  
  .. .. .. .. ..$ num.bin            : num 20
  .. .. .. .. ..$ binning.method     : chr "equal_width"
  .. .. .. .. ..$ nfeatures          : num 2000
  .. .. .. .. ..$ mean.cutoff        : num [1:2] 0.1 8
  .. .. .. .. ..$ dispersion.cutoff  : num [1:2] 1 Inf
  .. .. .. .. ..$ verbose            : logi TRUE
  .. ..$ ScaleData.RNA           :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. .. .. ..@ name       : chr "ScaleData.RNA"
  .. .. .. ..@ time.stamp : POSIXct[1:1], format: "2024-03-18 19:37:00"
  .. .. .. ..@ assay.used : chr "RNA"
  .. .. .. ..@ call.string: chr "ScaleData(seurat.obj_combined_filtered)"
  .. .. .. ..@ params     :List of 9
  .. .. .. .. ..$ assay             : chr "RNA"
  .. .. .. .. ..$ 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
  .. .. .. .. ..$ verbose           : logi TRUE
  .. ..$ RunPCA.RNA              :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. .. .. ..@ name       : chr "RunPCA.RNA"
  .. .. .. ..@ time.stamp : POSIXct[1:1], format: "2024-03-18 19:38:05"
  .. .. .. ..@ assay.used : chr "RNA"
  .. .. .. ..@ call.string: chr "RunPCA(seurat.obj_combined_filtered)"
  .. .. .. ..@ params     :List of 10
  .. .. .. .. ..$ assay          : chr "RNA"
  .. .. .. .. ..$ npcs           : num 50
  .. .. .. .. ..$ rev.pca        : logi FALSE
  .. .. .. .. ..$ weight.by.var  : logi TRUE
  .. .. .. .. ..$ verbose        : logi TRUE
  .. .. .. .. ..$ ndims.print    : int [1:5] 1 2 3 4 5
  .. .. .. .. ..$ nfeatures.print: num 30
  .. .. .. .. ..$ reduction.name : chr "pca"
  .. .. .. .. ..$ reduction.key  : chr "PC_"
  .. .. .. .. ..$ seed.use       : num 42
  .. ..$ FindNeighbors.RNA.pca   :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. .. .. ..@ name       : chr "FindNeighbors.RNA.pca"
  .. .. .. ..@ time.stamp : POSIXct[1:1], format: "2024-03-18 19:44:15"
  .. .. .. ..@ assay.used : chr "RNA"
  .. .. .. ..@ call.string: chr "FindNeighbors(seurat.obj_combined_filtered, dims = 1:20)"
  .. .. .. ..@ params     :List of 16
  .. .. .. .. ..$ reduction      : chr "pca"
  .. .. .. .. ..$ dims           : int [1:20] 1 2 3 4 5 6 7 8 9 10 ...
  .. .. .. .. ..$ assay          : chr "RNA"
  .. .. .. .. ..$ k.param        : num 20
  .. .. .. .. ..$ return.neighbor: logi FALSE
  .. .. .. .. ..$ compute.SNN    : logi TRUE
  .. .. .. .. ..$ prune.SNN      : num 0.0667
  .. .. .. .. ..$ nn.method      : chr "annoy"
  .. .. .. .. ..$ n.trees        : num 50
  .. .. .. .. ..$ annoy.metric   : chr "euclidean"
  .. .. .. .. ..$ nn.eps         : num 0
  .. .. .. .. ..$ verbose        : logi TRUE
  .. .. .. .. ..$ do.plot        : logi FALSE
  .. .. .. .. ..$ graph.name     : chr [1:2] "RNA_nn" "RNA_snn"
  .. .. .. .. ..$ l2.norm        : logi FALSE
  .. .. .. .. ..$ cache.index    : logi FALSE
  .. ..$ FindClusters            :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. .. .. ..@ name       : chr "FindClusters"
  .. .. .. ..@ time.stamp : POSIXct[1:1], format: "2024-03-19 15:06:18"
  .. .. .. ..@ assay.used : chr "RNA"
  .. .. .. ..@ call.string: chr [1:2] "FindClusters(seurat.obj_combined_filtered, resolution = c(0.4, " "    0.6, 0.8))"
  .. .. .. ..@ params     :List of 11
  .. .. .. .. ..$ graph.name      : chr "RNA_snn"
  .. .. .. .. ..$ cluster.name    : chr [1:3] "RNA_snn_res.0.4" "RNA_snn_res.0.6" "RNA_snn_res.0.8"
  .. .. .. .. ..$ modularity.fxn  : num 1
  .. .. .. .. ..$ resolution      : num [1:3] 0.4 0.6 0.8
  .. .. .. .. ..$ method          : chr "matrix"
  .. .. .. .. ..$ algorithm       : num 1
  .. .. .. .. ..$ n.start         : num 10
  .. .. .. .. ..$ n.iter          : num 10
  .. .. .. .. ..$ random.seed     : num 0
  .. .. .. .. ..$ group.singletons: logi TRUE
  .. .. .. .. ..$ verbose         : logi TRUE
  .. ..$ RunUMAP.RNA.pca         :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. .. .. ..@ name       : chr "RunUMAP.RNA.pca"
  .. .. .. ..@ time.stamp : POSIXct[1:1], format: "2024-03-19 15:07:33"
  .. .. .. ..@ assay.used : chr "RNA"
  .. .. .. ..@ call.string: chr "RunUMAP(seurat.obj_combined_filtered, dims = 1:20)"
  .. .. .. ..@ params     :List of 25
  .. .. .. .. ..$ dims                : int [1:20] 1 2 3 4 5 6 7 8 9 10 ...
  .. .. .. .. ..$ reduction           : chr "pca"
  .. .. .. .. ..$ assay               : chr "RNA"
  .. .. .. .. ..$ slot                : chr "data"
  .. .. .. .. ..$ umap.method         : chr "uwot"
  .. .. .. .. ..$ return.model        : logi FALSE
  .. .. .. .. ..$ n.neighbors         : int 30
  .. .. .. .. ..$ n.components        : int 2
  .. .. .. .. ..$ metric              : chr "cosine"
  .. .. .. .. ..$ learning.rate       : num 1
  .. .. .. .. ..$ min.dist            : num 0.3
  .. .. .. .. ..$ spread              : num 1
  .. .. .. .. ..$ set.op.mix.ratio    : num 1
  .. .. .. .. ..$ local.connectivity  : int 1
  .. .. .. .. ..$ repulsion.strength  : num 1
  .. .. .. .. ..$ negative.sample.rate: int 5
  .. .. .. .. ..$ uwot.sgd            : logi FALSE
  .. .. .. .. ..$ seed.use            : int 42
  .. .. .. .. ..$ angular.rp.forest   : logi FALSE
  .. .. .. .. ..$ densmap             : logi FALSE
  .. .. .. .. ..$ dens.lambda         : num 2
  .. .. .. .. ..$ dens.frac           : num 0.3
  .. .. .. .. ..$ dens.var.shift      : num 0.1
  .. .. .. .. ..$ verbose             : logi TRUE
  .. .. .. .. ..$ reduction.name      : chr "umap"
  ..@ tools       :List of 1
  .. ..$ BuildClusterTree:List of 4
  .. .. ..$ edge       : int [1:42, 1:2] 23 23 24 25 28 28 36 36 25 29 ...
  .. .. ..$ edge.length: num [1:42] 162.5 31.9 17.4 46.7 66.6 ...
  .. .. ..$ tip.label  : chr [1:22] "g0" "g1" "g2" "g3" ...
  .. .. ..$ Nnode      : int 21
  .. .. ..- attr(*, "class")= chr "phylo"
  .. .. ..- attr(*, "order")= chr "cladewise"

I basically just want to extract the sparse count matrix from this object so I can use it to run another software. I tried doing this below but it doesn't pull the genes names (rows) and the cell barcodes (columns)

filtered_combined_rhemac10_count_matrix <- seurat.obj_combined_filtered@assays$RNA@layers$counts

31405 x 56020 sparse Matrix of class "dgCMatrix"

[1,] . . . . . . . . . . . . . . . 1 . . . . . . 1 . 1 . . . . . 1 1 . . 1 1 . . . . . 1 . 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......
[2,] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......
[3,] 1 . . . . . . . . . . . 1 . . . . . . 1 . . . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 . . . . . . . . . . . . . . . 1 . . . 1 . ......
[4,] . . . . . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . . . . ......
[5,] . . . . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 . . . . . . . . . . . . . . 1 1 . . . . . . . . . . . . . . . . . . . . . ......
[6,] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......

 ..............................
 ........suppressing 55932 columns and 31394 rows in show(); maybe adjust options(max.print=, width=)
 ..............................

[31401,] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......
[31402,] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......
[31403,] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......
[31404,] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......
[31405,] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......
leonfodoulian commented 7 months ago

Hi @zgb963,

You should use the SeuratObject::GetAssayData() function.

filtered_combined_rhemac10_count_matrix <- SeuratObject::GetAssayData(object = seurat.obj_combined_filtered,
                                                                      assay = "RNA",
                                                                      layer = "counts")

Hope this helps!

Best, Leon

zgb963 commented 7 months ago

Hi @zgb963,

You should use the SeuratObject::GetAssayData() function.

filtered_combined_rhemac10_count_matrix <- SeuratObject::GetAssayData(object = seurat.obj_combined_filtered,
                                                                      assay = "RNA",
                                                                      layer = "counts")

Hope this helps!

Best, Leon

Hi @leonfodoulian it worked, thank you!

samuel-marsh commented 7 months ago

Hi @zgb963,

Yes, as @leonfodoulian states GetAssayData will work. However, for future GetAssayData has been superseded by LayerData which will do the same thing.

Best, Sam