Skip to content

Commit a36040f

Browse files
committed
finish seurat and MAGIC
1 parent ad429c5 commit a36040f

15 files changed

Lines changed: 359 additions & 148 deletions

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
pars*.rds
1010
deng.csv
1111
scimpute_count.txt
12+
MAGIC_count.csv
1213
totalCounts_by_cell.rds
1314
clust.rds
1415
tung/reads.rds

‎17-clust-intro.Rmd‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,10 @@ knitr::include_graphics("figures/sc3.png")
118118
* Based on __tSNE__ maps
119119
* Utilises _k_-means
120120

121-
#### [SEURAT](https://github.com/satijalab/seurat)
122-
123-
In the newest versions of SEURAT (v. 1.3-1.4) the clustering is based on a _community detection_ approach similar to one previously proposed for analyzing CyTOF data [@Levine2015-fk]. __tSNE__ is only used exclusively for visualization. In the next chapter we will be using the latest version of `SEURAT`.
124-
125-
__Note__
121+
#### [SNN-Cliq](http://bioinfo.uncc.edu/SNNCliq/)
126122

127-
In the original version `SEURAT` [@Macosko2015-ix] first utilised PCA on a set of cells, then a number of statistically significant PCs were defined. Those PCs were further projected to a 2D space using tSNE. The remaining cells were projected on the same tSNE map. Density clustering algorithm ([DBSCAN](https://en.wikipedia.org/wiki/DBSCAN)) was then used to identify cell clusters in the 2D space.
123+
`SNN-Cliq` [@Xu2015-vf] is a graph-based method. First the method identifies the k-nearest-neighbours of each cell according to the _distance_ measure. This is used to calculate the number of Shared Nearest Neighbours (SNN) between each pair of cells. A graph is built by placing an edge between two cells If they have at least one SNN. Clusters are defined as groups of cells with many edges between them using a "clique" method. SNN-Cliq requires several parameters to be defined manually.
128124

129-
#### [SNN-Cliq](http://bioinfo.uncc.edu/SNNCliq/)
125+
#### [Seurat](https://github.com/satijalab/seurat)
130126

131-
SNN-Cliq [@Xu2015-vf] is a graph-based method. First the method identifies the k-nearest-neighbours of each cell according to the _distance_ measure. This is used to calculate the number of Shared Nearest Neighbours (SNN) between each pair of cells. A graph is built by placing an edge between two cells If they have at least one SNN. Clusters are defined as groups of cells with many edges between them using a "clique" method. SNN-Cliq requires several parameters to be defined manually.
127+
`Seurat` clustering is based on a _community detection_ approach similar to `SNN-Cliq` and to one previously proposed for analyzing CyTOF data [@Levine2015-fk]. Since `Seurat` has become more like an all-in-one tool for scRNA-seq data analysis we dedicate a separate chapter to discuss it in more details (chapter \@ref(seurat)).

‎18-clustering.Rmd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ library(SC3)
1616
library(scater)
1717
library(SingleCellExperiment)
1818
library(pheatmap)
19-
library(irr)
19+
library(mclust)
2020
set.seed(1234567)
2121
```
2222

‎19-seurat.Rmd‎

Lines changed: 0 additions & 125 deletions
This file was deleted.

‎20-dropouts.Rmd‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ the total amount of data to be processed.
3636
For scRNASeq data, we will be focusing on unsupervised methods of feature
3737
selection which don't require any a priori information, such as cell-type
3838
labels or biological group, since they are not available, or may be unreliable,
39-
for many experiments. In contrast, differential expression (Chapter \ref())
39+
for many experiments. In contrast, differential expression (chapter \@ref(dechapter))
4040
can be considered a form of supervised feature selection since it uses the
4141
known biological label of each sample to identify features (i.e. genes) which
4242
are expressed at different levels across groups.
@@ -53,7 +53,7 @@ which removes cells with few detected genes, removes
5353
undetected genes, and converts raw counts to CPM.
5454

5555
```{r}
56-
deng_list <- M3Drop::M3DropCleanData(
56+
deng_list <- M3DropCleanData(
5757
counts(deng),
5858
labels = cellLabels,
5959
min_detected_genes = 100,
@@ -112,7 +112,7 @@ CI. Pink dots are the genes with significant biological variability
112112
after multiple-testing correction.
113113

114114
```{r, fig.width = 7, fig.height = 6}
115-
Brennecke_HVG <- M3Drop::BrenneckeGetVariableGenes(
115+
Brennecke_HVG <- BrenneckeGetVariableGenes(
116116
expr_matrix,
117117
fdr = 0.01,
118118
minBiolDisp = 0.5
@@ -156,7 +156,7 @@ We use M3Drop to identify significant outliers to the right of the MM
156156
curve. We also apply 1% FDR multiple testing correction:
157157

158158
```{r, fig.width = 7, fig.height = 6}
159-
M3Drop_genes <- M3Drop::M3DropFeatureSelection(
159+
M3Drop_genes <- M3DropFeatureSelection(
160160
expr_matrix,
161161
mt_method = "fdr",
162162
mt_threshold = 0.01
@@ -233,7 +233,7 @@ We can check whether the identified features really do represent genes different
233233
cell-types in this dataset.
234234

235235
```{r, fig.width = 7, fig.height = 10}
236-
M3Drop::M3DropExpressionHeatmap(
236+
M3DropExpressionHeatmap(
237237
M3Drop_genes,
238238
expr_matrix,
239239
cell_labels = celltype_labs

‎21-pseudotime.Rmd‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ which is based on a mixture of normal distributions. Then it builds a minimum sp
8383

8484
First we will try to use all genes to order the cells.
8585
```{r tscan-all-genes}
86-
deng <- readRDS("deng/deng-reads.rds")
87-
cellLabels <- colData(deng)$cell_type2
88-
deng <- logcounts(deng)
86+
deng_counts <- readRDS("deng/deng-reads.rds")
87+
cellLabels <- colData(deng_counts)$cell_type2
88+
deng <- logcounts(deng_counts)
8989
colnames(deng) <- cellLabels
9090
procdeng <- TSCAN::preprocess(deng)
9191
colnames(procdeng) <- 1:ncol(deng)
@@ -131,7 +131,7 @@ Unfortunately, Monocle does not work when all the genes are used, so
131131
we must carry out feature selection. First, we use M3Drop:
132132
```{r m3d-select-genes}
133133
m3dGenes <- as.character(
134-
M3Drop::M3DropFeatureSelection(deng)$Gene
134+
M3DropFeatureSelection(counts(deng_counts))$Gene
135135
)
136136
d <- deng[which(rownames(deng) %in% m3dGenes), ]
137137
d <- d[!duplicated(rownames(d)), ]

‎22-imputation.Rmd‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,17 @@ Based on the PCA and the clustering results, do you think that imputation is a g
8181

8282
### MAGIC
8383

84-
```{r, eval = FALSE}
85-
res <- readRDS("deng/deng_MAGIC.rds")
84+
```{r}
85+
system("MAGIC.py -d deng.csv -o MAGIC_count.csv --cell-axis columns -l 1 --pca-non-random csv")
86+
```
87+
88+
```{r}
89+
res <- read.csv("MAGIC_count.csv", header = TRUE)
90+
rownames(res) <- res[,1]
91+
res <- res[,-1]
92+
res <- t(res)
8693
res <- SingleCellExperiment(
87-
assays = list(logcounts = as.matrix(res)),
94+
assays = list(logcounts = res),
8895
colData = colData(deng)
8996
)
9097
plotPCA(

‎23-de-intro.Rmd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
knit: bookdown::preview_chapter
33
---
44

5-
## Differential Expression (DE) analysis
5+
## Differential Expression (DE) analysis {#dechapter}
66

77
```{r, echo=FALSE}
88
library(knitr)

0 commit comments

Comments
 (0)