knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Install all packages in the latest version of R. The package works for R >=4.1.
devtools::install_github("lizamathews/CAISC")
# load all necessary package libraries library(CAISC) library(igraph) library(leiden) library(leidenAlg) library(InteractiveComplexHeatmap) library(tidyverse) # data manipulation library(cluster) # clustering algorithms library(factoextra) # clustering visualization library(dendextend) # for comparing two dendrograms
If you have any questions or problems, please feel free to open a new issue here. You can also email the maintainers of the package -- the contact information is below.
Shouguo Gao (shouguo dot gao at nih dot gov)
NHLBI Hematopoiesis and Bone Marrow Failure Lab, Bethesda, MD
Jeerthi Kannan (jeerthi dot kannan at gmail dot com)
NHLBI Hematopoiesis and Bone Marrow Failure Lab, Bethesda, MD
Liza Mathews (liza mathews 5 at gmail dot com)
NHLBI Hematopoiesis and Bone Marrow Failure Lab, Bethesda, MD
knitr::include_graphics("https://raw.githubusercontent.com/lizamathews/CAISC/master/figures/figure1.jpg")
Figure 1. A flowchart outlining the procedures for CAISC.
# find paths of raw data files vcfPath<-system.file("extdata", "GSE57872_merged.vcf", package = "CAISC") sampleidPath<-system.file("extdata", "SRR_ID.txt", package = "CAISC") expmatPath<-system.file("extdata", "expressionmatrix_28_29.txt", package = "CAISC") cellPath<-system.file("extdata", "annotationCell_28_29.txt", package = "CAISC") genePath<-system.file("extdata", "annotationGene_28_29.txt", package = "CAISC")
Create a matrix of SNV mutations from a VCF file of mutations that appear in a minimal number of cells.
# create SNV matrix of mutations createSNVMatrix(vcfPath, "DENDRO_input_10mutations.rda", sampleidPath, "snvDistanceMatrix.csv")
Then, create a matrix of CNV mutations from a raw counts matrix containing assigned read counts, a sample annotation file, and a gene ordering file. Run only on a HPC cluster or a computer with at least 8 CPUs per task, 10GB of RAM, and 10GB of local scratch space
# create CNV matrix of mutations createCNVMatrix(expmatPath, cellPath, genePath, "CSC", "GSE57872.RData")
Next, create an integrated matrix with the created SNV and CNV matrices as input.
#load snv and cnv matrices snv_matrix <- as.matrix(read.csv("snvDistanceMatrix.csv", row.names = 1, header = TRUE)) cnv_matrix <- as.matrix(read.csv("CNVdistMatrix.zscore.csv", row.names = 1, header = TRUE)) # create and save integrated matrix integrated_matrix <- createIntegratedMatrix(cnv_matrix, snv_matrix) write.csv(integrated_matrix, file="integratedMatrix.csv", quote = FALSE)
Create an interactive complex heatmap from the SNV, CNV, integrated matrices, infercnv object, and the same gene ordering file used to create the CNV matrix.
# create interactive complex heatmap heatmap <- createComplexHeatmap(snv_matrix, cnv_matrix, integrated_matrix, "GSE57872.RData", genePath)
Use Shiny web app to interactively examine the complex heatmap.
# use shiny to examine heatmap ht_shiny(heatmap)
The following is a static heatmap, but the interactive heatmap can be opened in the Shiny web app.
knitr::include_graphics("https://raw.githubusercontent.com/lizamathews/CAISC/master/figures/SampleHeatmapMGH28_29.png")
Create tanglegram of SNV and CNV clustering results, and calculate cophenetic correlation
# find cells in both snv and cnv matrices snv_matrix<-(snv_matrix-mean(snv_matrix))/sd(snv_matrix) overlapCells<-intersect(row.names(snv_matrix), rownames(cnv_matrix)) # find clusters in snv matrix clust1=hclust(as.dist(snv_matrix[overlapCells,overlapCells]),method='ward.D') dend1=as.dendrogram(clust1) # find clusters in cnv matrix clust2=hclust(as.dist(cnv_matrix[overlapCells,overlapCells]),method='ward.D') dend2=as.dendrogram(clust2) # create tanglegram and find cophenetic correlation tanglegram(dend1, dend2, margin_inner = 10) cor.dendlist(dendlist(dend1=dend1, dend2=dend2))
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.