-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
120 lines (83 loc) · 3.55 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
output: md_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# scEC
<!-- badges: start -->
<!-- badges: end -->
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](https://github.com/) with:
``` r
# 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).
```{r, include = FALSE}
Path <- "~/OneDrive - University of Southampton/Data/Tian2018/ThreeClasses/"
```
```{r example, dpi=300}
library(scEC)
library(Matrix)
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)))
```
```{r, dpi=300}
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.
```{r, include = FALSE}
Path2 <- "~/OneDrive - University of Southampton/Data/Tian2018/"
```
```{r, message = FALSE}
library("org.Hs.eg.db")
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.
```{r}
Ident <- scEC::Map(MapCountsMatrix = MapCountsMatrix,
ReferenceCountsMatrix = ReferenceCountsMatrix,
ReferenceID = ReferenceID)
knitr::kable(table(Ident, MapID))
```