Skip to content

infercnv 10x

Brian Haas edited this page Oct 31, 2018 · 7 revisions

Leveraging 10x count data in InferCNV

Below provides an example of how you might generate a counts matrix for use with inferCNV, starting with 10x data.

Here, we'll use Seurat for converting 10x count data to a CP100k matrix.

library(Seurat)                                                                                           
                                                                                                          
data = Read10X(data.dir = "10x_data_dir/") 
seurat_obj = CreateSeuratObject(raw.data=data, min.cells=3, min.genes=200)
counts_matrix = as.matrix(seurat_obj@raw.data[,seurat_obj@cell.names])

# use more palatable column names (cell identifiers)            
cell.names <- sapply(seq_along(colnames(counts_matrix)), function(i) paste0("cell_", i), USE.NAMES = F)      
colnames(counts_matrix) = cell.names    

# write the output table 
write.table(round(counts_matrix, digits=3), file='sc.10x.counts.matrix', quote=F, sep="\t")                   
                                                                                           

Now, the 'cp100k.log2.matrix' is ready for use with InferCNV.

Clone this wiki locally