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 |
對(duì)象信息使用標(biāo)準(zhǔn)R函數(shù)可以快速輕松地獲得有關(guān)Seurat對(duì)象的摘要信息》梅蓿可以使用dim
,ncol
和nrow
函數(shù)找到對(duì)象的形狀/尺寸。細(xì)胞和特征名稱可以分別使用colnames
和rownames
函數(shù)或dimnames
函數(shù)找到成箫。通過(guò)使用names
,可以找到Seurat對(duì)象中包含的Assay
旨枯,DimReduc
和Graph
對(duì)象的名稱向量蹬昌。
# 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"
可以使用 "[[" 來(lái)提取特定的Assay
,DimReduc
或Graph
對(duì)象攀隔。還可以使用 "[[" 將新對(duì)象添加到Seurat對(duì)象中皂贩;Seurat將找出新的關(guān)聯(lián)對(duì)象在Seurat
對(duì)象中的位置。
> 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
函數(shù)可以從Seurat對(duì)象訪問(wèn)數(shù)據(jù)昆汹∶魉ⅲ可以使用SetAssayData
將數(shù)據(jù)添加到counts
,data
或scale.data
插槽中满粗。新數(shù)據(jù)必須具有與當(dāng)前數(shù)據(jù)相同順序的相同細(xì)胞辈末。添加到counts'或
data`中的數(shù)據(jù)必須具有與當(dāng)前數(shù)據(jù)相同的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...
可以使用單個(gè)[
或使用$
來(lái)訪問(wèn)細(xì)胞水平注釋數(shù)據(jù)映皆。盡管已經(jīng)為它啟用了制表符自動(dòng)完成功能挤聘,使其成為交互式使用的理想選擇,但是使用$
來(lái)訪問(wèn)意味著一次只能提取一點(diǎn)數(shù)據(jù)捅彻。也可以使用單個(gè)[
或使用AddMetaData
添加細(xì)胞水平注釋數(shù)據(jù)组去。
# 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
函數(shù)從Assay
對(duì)象中提取特征均值和離散度〔窖停可變特征向量可以通過(guò)VariableFeatures
函數(shù)提取从隆。VariableFeatures
也可以設(shè)置可變特征向量诚撵。
# 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
可以通過(guò)Stdev
找到Seurat對(duì)象中存儲(chǔ)的DimReduc
的標(biāo)準(zhǔn)差向量。
> 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
可以通過(guò)以下方法找到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