a1_Introduction.RmdscCNVis is an R package for exploring single-cell copy number data.
All plotting functions take as input an scCNVisObject.
Example data has been provided to show how this is done, as described
below. The primary method for creating a scCNVisObject
requires you to manually specify multiple inputs, but helper functions
exist to directly import output formats from some popular CNV calling
tools (see bottom of this page for details).
##Default method
For the default method, you first need an input matrix containing the copy number values. Here, we use the provided example data, which is adapted from the example data provided by the infercnv package.
library(scCNVis)
#Example matrix
#Rows = cells, Columns = Genomc regions, Values = Copy number values (or a similar metric)
#Row names and column names are optional, because the cell names and column
#info will be provided separately
#In this example, the provided matrix uses genes as column names. The column
#names can be anything that you want, as long as they correspond to regions in
#the genome described by the GenomicRanges object provided (below)
matrix <- example.matrix
print(dim(matrix))
#> [1] 142 8508
print(matrix[1:5,1:5])
#> WASH7P LINC00115 NOC2L SDF4 UBE2J2
#> 93_P9_C07 0.7718469 0.7715603 0.7725591 0.7747470 0.7777515
#> 93_P8_E09 1.0039410 1.0039410 1.0039410 1.0039410 1.0039410
#> 93_P6_H11 0.8843598 0.8802596 0.8767246 0.8720894 0.8663517
#> 93_P6_C07 0.6607175 0.6626568 0.6645759 0.6678009 0.6710559
#> 93_P9_C04 1.0039410 1.0039410 1.0039410 1.0039410 1.0039410Second, is the example cell names:
cells <- example.cells
#The number of cell names should be the same as the number of rows as the input
#matrix, and should be in the same order as those rows
print(length(cells))
#> [1] 142
print(cells[1:5])
#> [1] "93_P9_C07" "93_P8_E09" "93_P6_H11" "93_P6_C07" "93_P9_C04"Third, is a GenomicRanges::GRanges object. It should
have the same length as the number of columns in the input matrix, where
each entry describes a genomic bin. Bins are expected to be
region-sorted and non-overlapping.
granges <- example.granges
print(granges)
#> GRanges object with 8508 ranges and 0 metadata columns:
#> seqnames ranges strand
#> <Rle> <IRanges> <Rle>
#> WASH7P chr1 14363-29806 *
#> LINC00115 chr1 761586-762902 *
#> NOC2L chr1 879584-894689 *
#> SDF4 chr1 1152288-1167411 *
#> UBE2J2 chr1 1189289-1209265 *
#> ... ... ... ...
#> NCAPH2 chr22 50946645-50961901 *
#> SCO2 chr22 50961997-50964868 *
#> CPT1B chr22 51007290-51017899 *
#> CHKB chr22 51017378-51039884 *
#> RABL2B chr22 51205929-51222091 *
#> -------
#> seqinfo: 22 sequences from an unspecified genome; no seqlengthsFinally, is the input meta data. This is a data.frame where each row
corresponds to a cell. At a minimum, this should have a
Sample column describing what sample the cell came from,
but can include an arbitrary amount of other data as well. In this
example, our meta data also includes subclone identifiers generated by
infercnv. Row names should be the provided cell names and correspond to
the provided cell matrix. The matrix and meta data are expected to be in
the same order.
meta <- example.meta
print(head(meta))
#> Sample Subclone
#> 93_P9_C07 Example.Sample malignant_93
#> 93_P8_E09 Example.Sample malignant_93
#> 93_P6_H11 Example.Sample malignant_93
#> 93_P6_C07 Example.Sample malignant_93
#> 93_P9_C04 Example.Sample malignant_93
#> 93_P8_B06 Example.Sample malignant_93These inputs can be used to create a scCNVis object:
obj <- scCNVis::createPlotObject(input.matrix = matrix,
cell.names = cells,
granges = granges,
meta = meta)##Importing from infercnv
If CNV calls were generated using infercnv, it is possible to
generate a scCNVisObject directly from the resulting
run.final.infercnv.obj. An example of such an object has
been included with scCNVis. It can be used to create a
scCNVisObject as follows:
#grab the provided example object
infercnv.obj <- example.infercnv.obj
obj <- scCNVis::createPlotObjectFromInfercnv(infercnv.obj = infercnv.obj,
sample.name = "Example.Sample")See the additional documentation articles about making frequency
plots, heatmaps and line plots for examples of how to use the
scCNVis object.