Reference
Install
-
Install
一定要先装JAGS
,我在conda环境中安装了(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
- 两步:先输入三个文件构建对象
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 开始构建对象
- 刚开始用自己的数据集一直卡死,服务器内存不够,还是subset细胞类型了。
library(Seurat)
library(infercnv)
#查看数据
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"))
。。。
网友评论