@sjcrh/proteinpaint-server 2.14.4 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/genome/genome.sql +54 -0
- package/package.json +5 -5
- package/server.js +1 -2
- package/shared/common.js +2 -1
- package/utils/fastclust.R +129 -0
- package/utils/lowess.R +9 -0
- package/server.js.LICENSE.txt +0 -1
package/shared/common.js
CHANGED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Usage:
|
|
2
|
+
# time Rscript fastclust.R in.json
|
|
3
|
+
|
|
4
|
+
# Image is in Rplots.pdf
|
|
5
|
+
|
|
6
|
+
# Checking if all R packages are installed or not, if not installing each one of them
|
|
7
|
+
|
|
8
|
+
ggplot2_path <- system.file(package='ggplot2')
|
|
9
|
+
if (nchar(ggplot2_path) == 0) {
|
|
10
|
+
install.packages("ggplot2", repos='https://cran.case.edu/')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
jsonlite_path <- system.file(package='jsonlite')
|
|
14
|
+
if (nchar(jsonlite_path) == 0) {
|
|
15
|
+
install.packages("jsonlite", repos='https://cran.case.edu/')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
dendextend_path <- system.file(package='dendextend')
|
|
19
|
+
if (nchar(dendextend_path) == 0) {
|
|
20
|
+
install.packages("dendextend", repos='https://cran.case.edu/')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
reshape_path <- system.file(package='reshape')
|
|
24
|
+
if (nchar(reshape_path) == 0) {
|
|
25
|
+
install.packages("reshape", repos='https://cran.case.edu/')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#flashClust_path <- system.file(package='flashClust')
|
|
29
|
+
#if (nchar(flashClust_path) == 0) {
|
|
30
|
+
# install.packages("flashClust", repos='https://cran.case.edu/')
|
|
31
|
+
#}
|
|
32
|
+
|
|
33
|
+
suppressPackageStartupMessages(library(dendextend))
|
|
34
|
+
library(jsonlite)
|
|
35
|
+
#library(flashClust)
|
|
36
|
+
library(dendextend)
|
|
37
|
+
library(reshape)
|
|
38
|
+
library(ggplot2)
|
|
39
|
+
|
|
40
|
+
# Distance matrix
|
|
41
|
+
args <- commandArgs(trailingOnly = T)
|
|
42
|
+
if (length(args) != 1) stop("Usage: Rscript test.R in.json > results")
|
|
43
|
+
infile <- args[1]
|
|
44
|
+
input <- fromJSON(infile)
|
|
45
|
+
|
|
46
|
+
# For columns (i.e samples)
|
|
47
|
+
RowDist <- dist(input$matrix, method = "euclidean") # Transposing the matrix
|
|
48
|
+
|
|
49
|
+
# Hierarchical clustering
|
|
50
|
+
print (input$cluster_method)
|
|
51
|
+
RowDend <- hclust(RowDist, method = tolower(input$cluster_method))
|
|
52
|
+
#RowDend <- flashClust(RowDist, method = tolower(input$cluster_method))
|
|
53
|
+
#print (RowDend$order)
|
|
54
|
+
#print ("Merge")
|
|
55
|
+
#print (RowDend$merge)
|
|
56
|
+
#print ("Height")
|
|
57
|
+
#print (RowDend$height)
|
|
58
|
+
#print ("Labels")
|
|
59
|
+
#print (RowDend$labels)
|
|
60
|
+
#print ("Calls")
|
|
61
|
+
#print (RowDend$call)
|
|
62
|
+
#print ("Attributes")
|
|
63
|
+
#attributes(RowDend)
|
|
64
|
+
#print ("methods")
|
|
65
|
+
#methods(class=class(RowDend))
|
|
66
|
+
RowDendro <- as.dendrogram(RowDend)
|
|
67
|
+
#print ("Attributes as.dendrogram")
|
|
68
|
+
#attributes(RowDendro)
|
|
69
|
+
plot(RowDendro)
|
|
70
|
+
|
|
71
|
+
node_coordinates <- get_nodes_xy(
|
|
72
|
+
RowDendro,
|
|
73
|
+
type = "rectangle"
|
|
74
|
+
)
|
|
75
|
+
print (node_coordinates)
|
|
76
|
+
|
|
77
|
+
# For columns (i.e samples)
|
|
78
|
+
ColumnDist <- dist(t(input$matrix), method = "euclidean") # Transposing the matrix
|
|
79
|
+
|
|
80
|
+
# Hierarchical clustering
|
|
81
|
+
|
|
82
|
+
ColumnDend <- hclust(ColumnDist, method = tolower(input$cluster_method))
|
|
83
|
+
#ColumnDend <- flashClust(ColumnDist,method = tolower(input$cluster_method))
|
|
84
|
+
ColumnDendro <- as.dendrogram(ColumnDend)
|
|
85
|
+
plot (ColumnDendro)
|
|
86
|
+
|
|
87
|
+
# Sorting the matrix
|
|
88
|
+
|
|
89
|
+
SortedMatrix <- input$matrix[RowDend$order, ColumnDend$order]
|
|
90
|
+
SortedRowNames <- input$row_names[RowDend$order]
|
|
91
|
+
SortedColumnNames <- input$col_names[ColumnDend$order]
|
|
92
|
+
|
|
93
|
+
m <- matrix(SortedMatrix,length(SortedRowNames),length(SortedColumnNames))
|
|
94
|
+
colnames(m) <- SortedColumnNames
|
|
95
|
+
rownames(m) <- SortedRowNames
|
|
96
|
+
|
|
97
|
+
df <- melt(m)
|
|
98
|
+
colnames(df) <- c("Genes", "Samples", "value")
|
|
99
|
+
|
|
100
|
+
ggplot(df, aes(x = Genes, y = Samples, fill = value)) +
|
|
101
|
+
geom_tile() + scale_fill_gradient(low="blue", high="red")
|
|
102
|
+
|
|
103
|
+
#ggsave("heatmap.png")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
##print (SortedMatrix)
|
|
107
|
+
#df <- as.data.frame(SortedMatrix)
|
|
108
|
+
#rownames(df) <- SortedRowNames
|
|
109
|
+
#colnames(df) <- SortedColumnNames
|
|
110
|
+
#print ("DataFrame")
|
|
111
|
+
#print (df)
|
|
112
|
+
##plt <- ggplot(as.data.frame(SortedMatrix), aes(SortedColumnNames,SortedRowNames)) + geom_tile() + theme_minimal()
|
|
113
|
+
#plt <- ggplot(df,aes(x=colname,y=rownames(df))) + geom_tile() + theme_minimal()
|
|
114
|
+
#
|
|
115
|
+
## setting gradient color as red and white
|
|
116
|
+
#plt <- plt + scale_fill_gradient(low="blue", high="red")
|
|
117
|
+
#
|
|
118
|
+
## setting the title and subtitles using
|
|
119
|
+
## title and subtitle
|
|
120
|
+
#plt <- plt + labs(title = "Heatmap")
|
|
121
|
+
#plt <- plt + labs(subtitle = "A simple heatmap using geom_tile()")
|
|
122
|
+
#
|
|
123
|
+
## setting x and y labels using labs
|
|
124
|
+
#plt <- plt + labs(x ="Samples", y ="Genes")
|
|
125
|
+
#
|
|
126
|
+
## plotting the Heatmap
|
|
127
|
+
#plt
|
|
128
|
+
#png("heatmap.png")
|
|
129
|
+
#dev.off()
|
package/utils/lowess.R
ADDED
package/server.js.LICENSE.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//!!! DO NOT USE FOR geneVariant filterCTE constructor
|