-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckRobust.Rmd
79 lines (72 loc) · 1.85 KB
/
checkRobust.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
---
title: "checkRobust"
author: "Gaurav"
date: "12/20/2019"
output: html_document
---
```{r setup, include=FALSE}
library(dplyr)
library(projectR)
load('objects.rda')
```
Generate gene sets
```{r}
mesoGenes <- c("sna","Cyp310a1","htl")
dorsalEctoGenes <- c("zen","zen2")
```
Remove Gene sets
```{r}
datMeso <- insitu.matrix[,!(colnames(insitu.matrix) %in% mesoGenes)]
datDorsoEcot <- insitu.matrix[,!(colnames(insitu.matrix) %in% dorsalEctoGenes)]
```
Perform projections on modified datasets
```{r}
projMeso <- projectR(t(datMeso),dataCogaps)
projDorsEcto <- projectR(t(datDorsoEcot),dataCogaps)
```
Function to get correlation
```{r get Cor}
getCor <- function(mat1,mat2){
sapply(1:nrow(mat1),function(i) return(cor(mat1[i,],mat2[i,])))
}
```
### Get correlation b/w gene-set-removed projection and full projection
Removing mesodermic genes
```{r}
getCor(projMeso,projPosCgps$projection)
```
Removing dorsal ectodermic genes
```{r}
getCor(projDorsEcto,projPosCgps$projection)
```
Perfrom leave-one-out test
```{r}
corrLeaveOneOut <- sapply(1:84,function(i){
projection <- projectR(t(insitu.matrix[,-i]),dataCogaps)
getCor(projection,projPosCgps$projection)
})
```
```{r}
library(pheatmap)
colnames(corrLeaveOneOut) <- colnames(insitu.matrix)
rownames(corrLeaveOneOut) <- paste0('Pattern',1:20)
pheatmap(corrLeaveOneOut)
```
```{r include=F}
png('leaveOneOut.png',width = 10, height = 6, units = 'in',res=300)
pheatmap(corrLeaveOneOut)
dev.off()
```
Check random loadings projection
```{r}
rdm <- matrix(rnorm(8924*20),ncol = 20, nrow = 8924)
dimnames(rdm) <- dimnames(dataCogaps@featureLoadings)
randomProj <- projectR(t(insitu.matrix),rdm)
getCor(randomProj,projPosCgps$projection)
```
```{r}
rdm <- matrix(rnorm(3039*84),ncol = 84, nrow = 3039)
dimnames(rdm) <- dimnames(insitu.matrix)
randomProj <- projectR(t(rdm),dataCogaps)
getCor(randomProj,projPosCgps$projection)
```