Giter VIP home page Giter VIP logo

scec's Introduction

scEC

Single-cell Entropic Clustering (scEC) provides an entropy based approach to normalisation, feature selection, differential expression analysis and unsupervised clustering of single-cell RNA-sequencing data. Pre-print is avaialble at https://www.biorxiv.org/content/10.1101/2020.10.01.322255v4.

Installation

You can install the the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("mjcasy/scEC")

Note that the package has two python dependencies: Numpy and Scipy. You can download both via the reticulate package using py_install(“numpy”) and py_install(“scipy”).

Clustering

The basic workflow is demonstrated on the Tian et al 2018, single-cell mixology data set, a mixture of three cancerous cell lines (https://github.com/LuyiTian/sc_mixology).

library(scEC)
#> 
#> Attaching package: 'scEC'
#> The following object is masked from 'package:base':
#> 
#>     Map
library(Matrix)
#> Warning: package 'Matrix' was built under R version 4.1.2

load(paste0(Path, "CountsMatrix"))

CountsMatrix <- CountsMatrix[rowSums(CountsMatrix) >= 100,]

PopHet <- Population(CountsMatrix)
Mean <- log10(rowMeans(CountsMatrix))
N <- ncol(CountsMatrix)

plot(Mean, PopHet, ylim = c(0, log(N)))

GOI <- FeatureSelection(CountsMatrix)
CountsMatrix <- CountsMatrix[GOI,]
Mean <- Mean[GOI]

Clustering <- scEC::Cluster(CountsMatrix, numClus = 3)
InterCluster <- DifferentialExpression(CountsMatrix, Clustering)

plot(Mean, InterCluster)

Mapping to reference

A novel count matrix can be mapped onto a previously clustered, reference counts matrix. Such mapping is useful in clustering samples from tissues for which cell atlases have already been generated.

Tian et al 2018 also included an expanded data set, covering five cancerous cell lines, inclusive of the three cell lines cluster above. The above clustering can be repeated as a mapping, where each cell is mapped to a cellular identity in the reference data set.

First, the genes names of each data set must be aligned: the five cell line data set uses gene symbols whereas the three line data set uses ENSEMBL IDs.

library("org.Hs.eg.db") 
#> Warning: package 'S4Vectors' was built under R version 4.1.1

load(paste0(Path, "CountsMatrix"))
MapCountsMatrix <- CountsMatrix
load(paste0(Path, "Identity"))
MapID <- Identity

load(paste0(Path2, "CountsMatrix"))
ReferenceCountsMatrix <- CountsMatrix
load(paste0(Path2, "Identity"))
ReferenceID <- Identity

symbols <- mapIds(org.Hs.eg.db, 
                  keys = rownames(MapCountsMatrix), 
                  keytype="ENSEMBL",
                  column = "SYMBOL")

syms <- symbols[!is.na(symbols)]

MapCountsMatrix <- MapCountsMatrix[names(syms),]
MapCountsMatrix@Dimnames[[1]] <- unname(syms)

RefGenes <- row.names(ReferenceCountsMatrix)
MapGenes <- row.names(MapCountsMatrix)
CommonGenes <- intersect(RefGenes, MapGenes)

ReferenceCountsMatrix <- ReferenceCountsMatrix[CommonGenes,]
MapCountsMatrix <- MapCountsMatrix[CommonGenes,]

The gene-matched data sets can then be mapped.

Ident <- scEC::Map(MapCountsMatrix = MapCountsMatrix,
                   ReferenceCountsMatrix = ReferenceCountsMatrix, 
                   ReferenceID = ReferenceID)

knitr::kable(table(Ident, MapID))
H1975 H2228 HCC827
A549 29 5 15
H1975 276 2 0
H2228 0 308 1
H838 8 0 0
HCC827 0 0 258

scec's People

Contributors

mjcasy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.