CCInx Usage

Brendan Innes

2019-05-23

CCInx Usage

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.

Ranking nodes by differential expression between conditions

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.

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.

Ranking nodes by expression magnitude

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)
#> Loading required package: SingleCellExperiment
#> Loading required package: SummarizedExperiment
#> Loading required package: GenomicRanges
#> Loading required package: stats4
#> Loading required package: BiocGenerics
#> Loading required package: parallel
#> 
#> Attaching package: 'BiocGenerics'
#> The following objects are masked from 'package:parallel':
#> 
#>     clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
#>     clusterExport, clusterMap, parApply, parCapply, parLapply,
#>     parLapplyLB, parRapply, parSapply, parSapplyLB
#> The following objects are masked from 'package:stats':
#> 
#>     IQR, mad, sd, var, xtabs
#> The following objects are masked from 'package:base':
#> 
#>     anyDuplicated, append, as.data.frame, basename, cbind,
#>     colnames, dirname, do.call, duplicated, eval, evalq, Filter,
#>     Find, get, grep, grepl, intersect, is.unsorted, lapply, Map,
#>     mapply, match, mget, order, paste, pmax, pmax.int, pmin,
#>     pmin.int, Position, rank, rbind, Reduce, rownames, sapply,
#>     setdiff, sort, table, tapply, union, unique, unsplit, which,
#>     which.max, which.min
#> Loading required package: S4Vectors
#> 
#> Attaching package: 'S4Vectors'
#> The following object is masked from 'package:base':
#> 
#>     expand.grid
#> Loading required package: IRanges
#> 
#> Attaching package: 'IRanges'
#> The following object is masked from 'package:grDevices':
#> 
#>     windows
#> Loading required package: GenomeInfoDb
#> Loading required package: Biobase
#> Welcome to Bioconductor
#> 
#>     Vignettes contain introductory material; view with
#>     'browseVignettes()'. To cite Bioconductor, see
#>     'citation("Biobase")', and for packages 'citation("pkgname")'.
#> Loading required package: DelayedArray
#> Loading required package: matrixStats
#> 
#> Attaching package: 'matrixStats'
#> The following objects are masked from 'package:Biobase':
#> 
#>     anyMissing, rowMedians
#> Loading required package: BiocParallel
#> 
#> Attaching package: 'DelayedArray'
#> The following objects are masked from 'package:matrixStats':
#> 
#>     colMaxs, colMins, colRanges, rowMaxs, rowMins, rowRanges
#> The following objects are masked from 'package:base':
#> 
#>     aperm, apply, rowsum
#> class: SingleCellExperiment 
#> dim: 843 323 
#> metadata(0):
#> assays(1): logcounts
#> rownames(843): 1600012H06Rik 1700066M21Rik ... Zfyve27 Znrf3
#> rowData names(0):
#> colnames(323): TACTAGATGCTA AAATTCGTCGGT ... GCAAAATTTCAC
#>   TAAAACCTAATT
#> colData names(1): cellTypes

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")
#> Loading required package: scClustViz
#> Registered S3 methods overwritten by 'ggplot2':
#>   method         from 
#>   [.quosures     rlang
#>   c.quosures     rlang
#>   print.quosures rlang
#> -- Calculating gene detection rate per cluster --
#> -- Calculating mean detected gene expression per cluster --
#> -- Calculating mean gene expression per cluster --
lapply(gsl[1:3],head)
#> $ProjectionNeurons
#>                DetectRate MeanDetectGeneExpr MeanNormGeneExpr
#> 1600012H06Rik 0.034188034         0.96027540        -3.846653
#> 1700066M21Rik 0.042735043         0.60205847        -3.881925
#> 4931414P19Rik 0.034188034        -0.08063235        -4.823379
#> Abca1         0.017094017         1.26484824        -4.502413
#> Abhd15        0.008547009        -0.67777189        -6.893249
#> Acvr1         0.008547009         0.87558854        -5.736874
#> 
#> $CorticalPrecursors
#>               DetectRate MeanDetectGeneExpr MeanNormGeneExpr
#> 1600012H06Rik 0.01904762        -0.11515394        -5.599577
#> 1700066M21Rik 0.03809524        -0.11207464        -4.709306
#> 4931414P19Rik 0.02857143         0.05859855        -4.931774
#> Abca7         0.04761905        -0.43947291        -4.715466
#> Abcc8         0.13333333        -0.04928220        -2.926440
#> Ackr3         0.04761905         0.05591052        -4.252934
#> 
#> $IntermediateProgenitors
#>               DetectRate MeanDetectGeneExpr MeanNormGeneExpr
#> 1600012H06Rik 0.06930693          0.3824473        -3.423116
#> 1700066M21Rik 0.08910891          0.1107141        -3.335895
#> 4931414P19Rik 0.03960396         -0.6783537        -5.172877
#> Abca1         0.00990099         -2.0267104        -7.507622
#> Abca7         0.00990099         -1.6165331        -7.311758
#> Abcc8         0.07920792          0.2986867        -3.317917
inx <- BuildCCInx(GeneStatList=gsl,
                  Species="mmusculus")
#> Scaling node weights per cell type...
#> Building node metadata...
#> Building edge list...

head(inx$edges)
#>                                                                    nodeA
#> Abca1_ProjectionNeurons~Pltp_ProjectionNeurons   Abca1_ProjectionNeurons
#> Abca1_ProjectionNeurons~Slc1a5_ProjectionNeurons Abca1_ProjectionNeurons
#> Abca1_ProjectionNeurons~Slc7a1_ProjectionNeurons Abca1_ProjectionNeurons
#> Acvr1_ProjectionNeurons~Acvr1b_ProjectionNeurons Acvr1_ProjectionNeurons
#> Acvr1_ProjectionNeurons~Acvr2a_ProjectionNeurons Acvr1_ProjectionNeurons
#> Acvr1_ProjectionNeurons~Acvr2b_ProjectionNeurons Acvr1_ProjectionNeurons
#>                                                                     nodeB
#> Abca1_ProjectionNeurons~Pltp_ProjectionNeurons     Pltp_ProjectionNeurons
#> Abca1_ProjectionNeurons~Slc1a5_ProjectionNeurons Slc1a5_ProjectionNeurons
#> Abca1_ProjectionNeurons~Slc7a1_ProjectionNeurons Slc7a1_ProjectionNeurons
#> Acvr1_ProjectionNeurons~Acvr1b_ProjectionNeurons Acvr1b_ProjectionNeurons
#> Acvr1_ProjectionNeurons~Acvr2a_ProjectionNeurons Acvr2a_ProjectionNeurons
#> Acvr1_ProjectionNeurons~Acvr2b_ProjectionNeurons Acvr2b_ProjectionNeurons
#>                                                  edgeWeight
#> Abca1_ProjectionNeurons~Pltp_ProjectionNeurons    0.1713428
#> Abca1_ProjectionNeurons~Slc1a5_ProjectionNeurons  0.2671990
#> Abca1_ProjectionNeurons~Slc7a1_ProjectionNeurons  0.1981018
#> Acvr1_ProjectionNeurons~Acvr1b_ProjectionNeurons  0.3138731
#> Acvr1_ProjectionNeurons~Acvr2a_ProjectionNeurons  0.2667038
#> Acvr1_ProjectionNeurons~Acvr2b_ProjectionNeurons  0.3765668
head(inx$nodes)
#>                                                            node
#> 1600012H06Rik_ProjectionNeurons 1600012H06Rik_ProjectionNeurons
#> 1700066M21Rik_ProjectionNeurons 1700066M21Rik_ProjectionNeurons
#> 4931414P19Rik_ProjectionNeurons 4931414P19Rik_ProjectionNeurons
#> Abca1_ProjectionNeurons                 Abca1_ProjectionNeurons
#> Abhd15_ProjectionNeurons               Abhd15_ProjectionNeurons
#> Acvr1_ProjectionNeurons                 Acvr1_ProjectionNeurons
#>                                          gene          cellType
#> 1600012H06Rik_ProjectionNeurons 1600012H06Rik ProjectionNeurons
#> 1700066M21Rik_ProjectionNeurons 1700066M21Rik ProjectionNeurons
#> 4931414P19Rik_ProjectionNeurons 4931414P19Rik ProjectionNeurons
#> Abca1_ProjectionNeurons                 Abca1 ProjectionNeurons
#> Abhd15_ProjectionNeurons               Abhd15 ProjectionNeurons
#> Acvr1_ProjectionNeurons                 Acvr1 ProjectionNeurons
#>                                 proteinType nodeWeight  DetectRate
#> 1600012H06Rik_ProjectionNeurons      Ligand 0.38054423 0.034188034
#> 1700066M21Rik_ProjectionNeurons      Ligand 0.37689638 0.042735043
#> 4931414P19Rik_ProjectionNeurons      Ligand 0.27952939 0.034188034
#> Abca1_ProjectionNeurons            Receptor 0.31272425 0.017094017
#> Abhd15_ProjectionNeurons             Ligand 0.06545941 0.008547009
#> Acvr1_ProjectionNeurons            Receptor 0.18505395 0.008547009
#>                                 MeanDetectGeneExpr MeanNormGeneExpr
#> 1600012H06Rik_ProjectionNeurons         0.96027540        -3.846653
#> 1700066M21Rik_ProjectionNeurons         0.60205847        -3.881925
#> 4931414P19Rik_ProjectionNeurons        -0.08063235        -4.823379
#> Abca1_ProjectionNeurons                 1.26484824        -4.502413
#> Abhd15_ProjectionNeurons               -0.67777189        -6.893249
#> Acvr1_ProjectionNeurons                 0.87558854        -5.736874