seurat对象结构

Seurat

slot

slot function
assays A list of assays within this object
meta.data Cell-level meta data
active.assay Name of active, or default, assay
active.ident Identity classes for the current object
graphs A list of nearest neighbor graphs
reductions A list of DimReduc objects
project.name User-defined project name (optional)
tools Empty list. Tool developers can store any internal data from their methods here
misc Empty slot. User can store additional information here
version Seurat version used when creating the objec

对象信息使用标准R函数可以快速轻松地获得有关Seurat对象的摘要信息。可以使用dimncolnrow函数找到对象的形状/尺寸。细胞和特征名称可以分别使用colnamesrownames函数或dimnames函数找到。通过使用names,可以找到Seurat对象中包含的AssayDimReducGraph对象的名称向量。

# The following examples use the PBMC 3k dataset
> pbmc
An object of class Seurat
 13714 features across 2638 samples within 1 assay
 2 dimensional reductions calculated: pca, tsne
# nrow and ncol provide the number of features and cells in the active assay, respectively
# dim provides both nrow and ncol at the same time
> dim(x = pbmc)
[1] 13714  2638
# In addtion to rownames and colnames, one can use dimnames
# which provides a two-length list with both rownames and colnames
> head(x = rownames(x = pbmc))
[1] "AL627309.1"    "AP006222.2"    "RP11-206L10.2" "RP11-206L10.9"
[5] "LINC00115"     "NOC2L"
> head(x = colnames(x = pbmc))
[1] "AAACATACAACCAC" "AAACATTGAGCTAC" "AAACATTGATCAGC" "AAACCGTGCTTCCG"
[5] "AAACCGTGTATGCG" "AAACGCACTGGTAC"
# A vector of names of associated objects can be had with the names function
# These can be passed to the double [[ extract operator to pull them from the Seurat object
> names(x = pbmc)
[1] "RNA"  "pca"  "tsne"

可以使用 "[[" 来提取特定的AssayDimReducGraph对象。还可以使用 "[[" 将新对象添加到Seurat对象中;Seurat将找出新的关联对象在Seurat对象中的位置。

> pbmc[['RNA']]
Assay data with 13714 features for 2638 cells
Top 10 variable features:
 PPBP, DOK3, NFE2L2, ARVCF, YPEL2, UBE2D4, FAM210B, CTB-113I20.2, GBGT1,
 GMPPA
> pbmc[['tsne']]
A dimensional reduction object with key tSNE_
 Number of dimensions: 2
 Projected dimensional reduction calculated: FALSE
 Jackstraw run: FALSE

使用GetAssayData函数可以从Seurat对象访问数据。可以使用SetAssayData将数据添加到countsdatascale.data插槽中。新数据必须具有与当前数据相同顺序的相同细胞。添加到counts'或data`中的数据必须具有与当前数据相同的features。

> GetAssayData(object = pbmc, slot = 'scale.data')[1:3, 1:3]
              AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC
AL627309.1       -0.06547546    -0.10052277    -0.05804007
AP006222.2       -0.02690776    -0.02820169    -0.04508318
RP11-206L10.2    -0.03596234    -0.17689415    -0.09997719
# SetAssayData example...

可以使用单个[或使用$来访问细胞水平注释数据。尽管已经为它启用了制表符自动完成功能,使其成为交互式使用的理想选择,但是使用$来访问意味着一次只能提取一点数据。也可以使用单个[或使用AddMetaData添加细胞水平注释数据。

# Cell-level meta data is stored as a data frame
# Standard data frame functions work on the meta data data frame
> colnames(x = pbmc[])
[1] "nGene"        "nUMI"         "orig.ident"   "percent.mito" "res.0.6"
# One can pull multiple values from the data frame at any time
> head(x = pbmc[c('nUMI', 'percent.mito')])
               nUMI percent.mito
AAACATACAACCAC 2421  0.030177759
AAACATTGAGCTAC 4903  0.037935958
AAACATTGATCAGC 3149  0.008897363
AAACCGTGCTTCCG 2639  0.017430845
AAACCGTGTATGCG  981  0.012244898
AAACGCACTGGTAC 2164  0.016643551
# The $ sigil can only pull bit of meta data at a time; however, tab-autocompletion
# has been enabled for the $ sigil, making it ideal for interactive use
> head(x = pbmc$percent.mito)
               percent.mito
AAACATACAACCAC  0.030177759
AAACATTGAGCTAC  0.037935958
AAACATTGATCAGC  0.008897363
AAACCGTGCTTCCG  0.017430845
AAACCGTGTATGCG  0.012244898
AAACGCACTGGTAC  0.016643551
# Passing `drop = TRUE` will turn the meta data into a names vector
# with each entry being named for the cell it corresponds to
> head(x = pbmc['res.0.6', drop = TRUE])
AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG
           "0"            "2"            "0"            "1"            "5"
AAACGCACTGGTAC
           "0"
# Add meta data example

HVFInfo函数从Assay对象中提取特征均值和离散度。可变特征向量可以通过VariableFeatures函数提取。VariableFeatures也可以设置可变特征向量。

# HVFInfo pulls mean, dispersion, and dispersion scaled
# Useful for viewing the results of FindVariableFeatures
> head(x = HVFInfo(object = pbmc))
                     mean dispersion dispersion.scaled
AL627309.1    0.013555659   1.432845        -0.6236875
AP006222.2    0.004695980   1.458631        -0.5728009
RP11-206L10.2 0.005672517   1.325459        -0.8356099
RP11-206L10.9 0.002644177   0.859264        -1.7556304
LINC00115     0.027437275   1.457477        -0.5750770
NOC2L         0.376037723   1.876440        -0.4162432
# VariableFeatures both accesses and sets the vector of variable features
> head(x = VariableFeatures(object = pbmc))
[1] "PPBP"   "DOK3"   "NFE2L2" "ARVCF"  "YPEL2"  "UBE2D4"
# Set variable features example

可以通过Stdev找到Seurat对象中存储的DimReduc的标准差向量。

> Stdev(object = pbmc, reduction.use = 'pca')
 [1] 5.666584 4.326466 3.952192 3.638124 2.191529 1.996551 1.877891 1.798251
 [9] 1.766873 1.753684 1.731568 1.720525 1.718079 1.715879 1.707009 1.702660
[17] 1.697318 1.692549 1.686149 1.683967

Methods

可以通过以下方法找到Seurat类:

library(Seurat)
utils::methods(class = 'Seurat')
  • [
  • [<-
  • [[
  • [[<-
  • colMeans
  • colSums
  • Command
  • DefaultAssay
  • DefaultAssay<-
  • dimnames
  • dim
  • GetAssayData
  • GetAssay
  • HVFInfo
  • Idents
  • Idents<-
  • merge
  • names
  • SetAssayData
  • Stdev
  • subset
  • SubsetData
  • VariableFeatures
  • VariableFeatures<-
  • WhichCells

你可能感兴趣的:(seurat对象结构)