knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.show = "hold" )
# Setup ---- library(CCInx) sysDr <- switch(Sys.info()["sysname"],"~/",Windows="D:/") inputDataPath <- paste0(sysDr,"Dropbox/GDB/RubinBrainEndo/Rubin_Data_for_Bader_Lab/190221/young_to_old_neuronal/") # Load DE results ----------------------- deL <- sapply(list.files(inputDataPath)[2:4],function(X) read.csv(paste0(inputDataPath,X),as.is=T),simplify=F) names(deL) <- sub(".csv$","",names(deL)) for (l in names(deL)) { deL[[l]] <- deL[[l]][!apply(deL[[l]],1,function(X) all(is.na(X) | X == "")),] rownames(deL[[l]]) <- deL[[l]]$Gene deL[[l]] <- deL[[l]][,-which(colnames(deL[[l]]) == "Gene")] deL[[l]] <- deL[[l]][order(deL[[l]]$padj),] deL[[l]] <- deL[[l]][1:2000,c("pval","padj","logFC_Young_to_Old","Percent_Pos_Cells_Young","Percent_Pos_Cells_Old")] names(deL[[l]])[3:5] <- c("logFC","DetectPctYoung","DetectPctOld") deL[[l]] <- deL[[l]][!is.na(deL[[l]]$logFC),] } save(deL,file="../inst/DemoData/DemoDE.RData")
CCInx takes cell type transcriptomes (generally from clustered scRNAseq data) and predicts cell-cell interaction networks. It generates both node and edgelists appropriate for importing into graph visualization software such as Cytoscape, and figures showing bipartite graphs for predicted interactions between pairs of cell types.
Here we'll demonstrate the standard use case using data from a recent study of aging mouse brain, where differential expression testing was performed between young and aging neuronal cell types. The input data is a list of data frames, where each named list entry represents a cell type, and its data frame contains the differential expression statistics for genes in that cell type.
library(CCInx) load(system.file("DemoData/DemoDE.RData",package="CCInx")) lapply(deL,head)
The CCInx network is built using the list of gene expression data frames. The output of BuildCCInx
is a list of cell type pairs, with each entry storing both the edge list and node metadata. These can be exported as .csv files for use in Cytoscape.
inx <- BuildCCInx(GeneStatList=deL, GeneMagnitude="logFC", GeneStatistic="padj", Species="mmusculus") head(inx$edges) head(inx$nodes)
PlotCCInx(INX=inx, cellTypeA="GABA",cellTypeB="DOPA", proteinTypeA="Receptor",proteinTypeB="Ligand", TopEdges=50) # Also check out ViewCCInx(inx) for a Shiny viewer!
If no comparisons have been made experimentally, CCInx can use gene expression magnitude to rank nodes in its predicted interactions. Here we use a subset of data from the developing murine cerebral cortex to demonstrate.
load(system.file("DemoData/DemoExpr.RData",package="CCInx")) show(e13cortex)
We can automatically generate the GeneStatList
input for BuildCCInx
from a Seurat
or SingleCellExperiment
object by using one of the functions from scClustViz, repurposed here in the following function:
gsl <- BuildGeneStatList(inD=e13cortex, cl=colData(e13cortex)$cellTypes, assayType="logcounts") lapply(gsl[1:3],head)
inx <- BuildCCInx(GeneStatList=gsl, Species="mmusculus") head(inx$edges) head(inx$nodes)
PlotCCInx(INX=inx, cellTypeA="ProjectionNeurons",cellTypeB="CorticalPrecursors", proteinTypeA="Ligand",proteinTypeB="Receptor", GeneMagnitudeThreshold=.5) # Also check out ViewCCInx(inx) for a Shiny viewer!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.