-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.Rmd
98 lines (86 loc) · 3.25 KB
/
test.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
---
title: "TEST"
author: "Bernd Jagla"
date: "2022-12-26"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
source("~/Rstudio/UTechSCB-SCHNAPPs/inst/app/serverFunctions.R", echo=F)
```
```{r}
doCalc <- input$scorpiusCalc
```
```{r som}
# "dimScorpiusX" %in% names(.schnappsEnv$defaultValues)
# "dimScorpiusY" %in% names(.schnappsEnv$defaultValues)
# .schnappsEnv$defaultValues[["dimScorpiusX"]]
# .schnappsEnv$defaultValues[["dimScorpiusY"]]
# "elpiStartNode" %in% names(.schnappsEnv$defaultValues)
#
# res2 = coE_somTrainReact()
# scEx <- isolate(scEx())
# scEx_log <- isolate(scEx_log())
# prjs <- isolate(sessionProjections$prjs)
# projFactors <- projFactors()
# projections <- isolate(projections())
# inp = reactiveValuesToList(input)
# somInputData = somInputData()
# coE_somMapReact = coE_somMapReact()
# coE_somTrainReact = coE_somTrainReact()
# coE_somGenesReact = coE_somGenesReact()
# coE_heatmapSOMReactive = coE_heatmapSOMReactive()
genesin <- input$coE_geneSOM
featureData <- rowData(scEx_log)
geneName = geneName2Index(genesin, featureData)
# coE_SOMcodebook = output$coE_SOMcodebook()
endpoints <- traj_endpoints()
save(file = "test.RData", list = c(ls(),".schnappsEnv"))
```
```{r umap}
umapData <- as.matrix(assays(scEx_log)[[1]])
compCases <- complete.cases(umapData)
save(file = "embedding.Rdata", list=c(ls()))
# cp = load("embedding.Rdata")
library(ggplot2)
# for (n_neighbors in seq(2,100,by =10)){
# for(spread in seq( 2,20, by=3)){
# for(min_dist in seq(0.01, 0.5, by = 0.08)){
# for (local_connectivity in seq(1, 20, by = 5)){
for (n_neighbors in c(2,50,100)){
for(spread in c( 2,5,10,20)){
for(min_dist in c(0.01, 0.2, 0.5)){
for (local_connectivity in c(1, 5, 10, 20)){
embedding <- tryCatch(uwot::umap(pca$x ,
n_neighbors = n_neighbors,
n_components = 3,
n_epochs = 2000,
# alpha = alpha,
init = "spectral",
spread = spread,
min_dist = min_dist,
set_op_mix_ratio = 1,
local_connectivity = local_connectivity,
bandwidth = 1,
# gamma = gamma,
negative_sample_rate = 5,
metric = "cosine",
n_threads = 8
), error = function(x)return(NULL))
if(is.null(embedding)) next()
embedding <- as.data.frame(embedding)
colnames(embedding) <- paste0("UMAP", 1:3)
rownames(embedding) <- colnames(scEx_log)
embedding$dbCluster = projections[rownames(embedding), "dbCluster"]
print(ggplot(embedding, aes(x=UMAP1, y=UMAP2, color=dbCluster)) + geom_point() +
ggtitle(paste("n_neighbors:", n_neighbors, " spread:", spread, " min_dist:", min_dist, " local_connectivity:", local_connectivity))
)
}
}
}
}
# embedding <- as.data.frame(embedding)
# colnames(embedding) <- paste0("UMAP", 1:n_components)
# rownames(embedding) <- colnames(scEx_log)
# save(file = "embedding.Rdata", list=c(ls()))
```