Reference
Install
-
Install
一定要先裝JAGS
,我在conda環(huán)境中安裝了(conda install r-rjags
)再BiocManager::install("infercnv")
Input (Data requirements)
具體說明在:(https://github.com/broadinstitute/inferCNV/wiki/File-Definitions).
我用了注釋過的seuratobject哗伯。
- a raw counts matrix of single-cell RNA-Seq expression
- an annotations file which indicates which cells are tumor vs. normal.
- a gene/chromosome positions file :
#https://github.com/broadinstitute/inferCNV/tree/master/scripts
#[infercnv/scripts/gtf_to_position_file.py at master · broadinstitute/infercnv (github.com)](https://github.com/broadinstitute/infercnv/blob/master/scripts/gtf_to_position_file.py)
#[data.broadinstitute.org/Trinity/CTAT/cnv/hg38_gencode_v27.txt](https://data.broadinstitute.org/Trinity/CTAT/cnv/hg38_gencode_v27.txt)
# By Default use gene_id as the name of your feature
python ./scripts/gtf_to_position_file.py your_reference.gtf your_gen_pos.txt
# You can change what gtf attribute key is used, here transcript_id is used.
python ./scripts/gtf_to_position_file.py --attribute_name transcript_id your_reference.gtf your_gen_pos.txt
Usage
- 兩步:先輸入三個文件構(gòu)建對象
CreateInfercnvObject
苇瓣;再 運行infercnv::run(infercnv_obj,...)
匠楚。
# create the infercnv object
infercnv_obj = CreateInfercnvObject(raw_counts_matrix="singleCell.counts.matrix",
annotations_file="cellAnnotations.txt",
delim="\t",
gene_order_file="gene_ordering_file.txt",
ref_group_names=c("normal"))
# perform infercnv operations to reveal cnv signal
infercnv_obj = infercnv::run(infercnv_obj,
cutoff=1, # use 1 for smart-seq, 0.1 for 10x-genomics
out_dir="output_dir", # dir is auto-created for storing outputs
cluster_by_groups=T, # cluster
denoise=T,
HMM=T
)
從SeuratObject 開始構(gòu)建對象
- 剛開始用自己的數(shù)據(jù)集一直卡死捷沸,服務(wù)器內(nèi)存不夠摊沉,還是subset細胞類型了。
library(Seurat)
library(infercnv)
#查看數(shù)據(jù)
seurat_object <- readRDS('seurat_object.rds')
levels(seurat_object)
#篩選分析需要的細胞類型
seurat_object <- subset(seurat_object, idents=c('Epithelial cells', 'Myeloid cells', 'T cells'))
#抽樣痒给,僅用于該教程
#seurat_object <- subset(seurat_object, downsample=200)
counts <- GetAssayData(seurat_object, y= 'counts')
anno <- data.frame(Idents(seurat_object))
infercnv_obj = CreateInfercnvObject(raw_counts_matrix = counts,
annotations_file = anno,
delim="\t",
gene_order_file = gene_order,
min_max_counts_per_cell = c(100, +Inf),
ref_group_names = c("Myeloid cells", "T cells"))
坯钦。。侈玄。