7
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Seuratオブジェクトの中身

Last updated at Posted at 2019-12-23

概要

Seuratオブジェクトの中身わからんので、しらべた
Seurat3.0

説明

Seuratで主に使われるオブジェクトは、Seurat, Assay, DimReducの3種類。階層構造になっていて、SeuratがAssayとDimReducを内包している。全部S4オブジェクト。

S4オブジェクトはオブジェクト名@スロット名でスロットの中身を参照できる。

オブジェクト名 大まかな中身
Seurat ぜんぶ
Array 生発現データ、前処理済みデータ
DimReduc 次元削減データ

Seurat

Assay, Dimreducオブジェクトを含み、細胞ごとのannotation行列などのメタデータも持っている。
持っているAssayは1つのことが多い。DimReducは次元削減の関数に通すと生成されていく。(RunPCA, RunTSNE等)
Seuratオブジェクトを関数に通したときに処理が行われるのはactive.assayで示されているArrayオブジェクトのみ。変更するにはDefaultAssay(Assayオブジェクト名)を使う。

スロット名 中身
assays 持っているAssayのリスト
reductions 持っているDimReducのリスト
meta.data 細胞ごとのデータ行列 (これ使って細胞を群分けしたりできる)
active.assay   デフォルトで使っているAssayの名前
version Seuratオブジェクト作ったときのSeuratのバージョン
各スロットにアクセスすると、このSeurat (immune.combined) はAssay2つ (RNA, integrated) とDimReduc2つ (pca, umap) を持っていることが分かる。

> immune.combined@assays
$RNA
Assay data with 14053 features for 13999 cells
First 10 features:
 AL627309.1, RP11-206L10.2, LINC00115, NOC2L, KLHL17, PLEKHN1,
HES4, ISG15, AGRN, C1orf159 

$integrated
Assay data with 2000 features for 13999 cells
Top 10 variable features:
 HBB, HBA2, HBA1, CCL4, CCL3, CCL7, TXN, GNLY, PPBP, APOBEC3B 
> immune.combined@reductions
$pca
A dimensional reduction object with key PC_ 
 Number of dimensions: 30 
 Projected dimensional reduction calculated:  FALSE 
 Jackstraw run: FALSE 
 Computed using assay: integrated 

$umap
A dimensional reduction object with key UMAP_ 
 Number of dimensions: 2 
 Projected dimensional reduction calculated:  FALSE 
 Jackstraw run: FALSE 
 Computed using assay: integrated 

このAssay/DimReducオブジェクトにアクセスするにはSeuratオブジェクト名@assays/reducitons$Assay/DimReducオブジェクト名もしくはSeuratオブジェクト[["Assay/DimReducオブジェクト名"]]とする。

> immune.combined@assays$RNA
Assay data with 14053 features for 13999 cells
First 10 features:
 AL627309.1, RP11-206L10.2, LINC00115, NOC2L, KLHL17, PLEKHN1,
HES4, ISG15, AGRN, C1orf159 

> immune.combined[["RNA"]]
Assay data with 14053 features for 13999 cells
First 10 features:
 AL627309.1, RP11-206L10.2, LINC00115, NOC2L, KLHL17, PLEKHN1,
HES4, ISG15, AGRN, C1orf159 
> immune.combined@reductions$pca
A dimensional reduction object with key PC_ 
 Number of dimensions: 30 
 Projected dimensional reduction calculated:  FALSE 
 Jackstraw run: FALSE 
 Computed using assay: integrated 

> immune.combined[["pca"]]
A dimensional reduction object with key PC_ 
 Number of dimensions: 30 
 Projected dimensional reduction calculated:  FALSE 
 Jackstraw run: FALSE 
 Computed using assay: integrated 

ちなみにSeuratオブジェクト名[["列の名前"]]でメタデータ行列の列に直接アクセスできる。

Assay

インプットした生の発現データ、標準化した発現データ、さらにスケーリングした発現データ等を持っているオブジェクト。
インプット時点ではcounts以外の3つのスロットは空で、Seuratオブジェクトを関数に通すと生成される。(NormalizeData, FindVariableFeatures等)

スロット名 中身
counts 生データ行列
data 標準化データ行列
scale.data スケーリングデータ行列
var.features 細胞間で発現量の分散が大きい遺伝子
これらのスロットの中身は行列かリストなので、Assayオブジェクト名@スロット名で取り出したら、普通にスライスできる。スロットを指定せずにスライスするとdataのスライスになる。

DimReduc

次元削減データを持つオブジェクト。

スロット名 中身
cell.embeddings 次元削減後の細胞の座標の行列
feature.loadings 各次元での遺伝子の重み(寄与度)の行列
一重括弧でスライスするとfeature.loadingsが呼び出され、二重括弧だとcell.embeddingsが呼び出される。
immune.combined[["pca"]][1:3,1:3]
              PC_1        PC_2         PC_3
HBB  -0.0001663964 0.004646209 -0.006053524
HBA2  0.0001534606 0.001399694 -0.005968729
HBA1 -0.0010221891 0.003000203 -0.004530499
> immune.combined[["pca"]][[1:3,1:3]]
                     PC_1       PC_2       PC_3
AAACATACATTTCC.1 11.73576 -1.0461628 -0.1920609
AAACATACCAGAAA.1 13.66566  1.7253273 -1.9862247
AAACATACCTCGCT.1 11.62503  0.6643166 -1.4059378

おわり

理解できて使いそうなところだけ載せたので、詳しく知りたい人はhttps://github.com/satijalab/seurat/wiki まで

7
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?