forked from zhutiansheng/BatchServer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglobal.R
56 lines (55 loc) · 1.46 KB
/
global.R
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
options(stringsAsFactors = F)
options(encoding = 'UTF-8')
options(shiny.maxRequestSize=5*1024^3)
set.seed(12345)
#load library
library(shiny)
library(shinydashboard)
library(sva)
library(fitdistrplus)
library(extraDistr)
library(umap)
library(ggplot2)
library(plotly)
library(Biobase)
library(pvca)
library(randomForest)
library(preprocessCore)
library(openxlsx)
#library(bladderbatch)#testdata
#import user defined functions
source('src/MyCombat.R')
environment(my_it.sol) <- asNamespace('sva')
environment(combat) <- asNamespace('sva')
source('src/MyPVCA.R')
source('src/MyPriorDraw.R')
environment(drawPrior) <- asNamespace('sva')
source("src/MyRandomForest.R")
effect_name="Please upload your sample information file"
dataCheck<-function(d){
error=NULL
if(ncol(d)<2){
error="Error: You may set wrong separator!"
}
else if(sum(duplicated(d[,1]))>0){
error="Error: The first column should be unique sample id/name!"
}
else{
cna<-apply(d[,-1], 1, function(x){sum(is.na(x))})
if(max(cna)==ncol(d[,-1])){
error = "Error: There exists feature (eg. prottein or gene) with all values are NA in the data matrix"
}
}
return(error)
}
missingValueReplace<-function(d,v){
if(v!="none"){
switch(v,
"1" = d[is.na(d)]<-1,
"0" = d[is.na(d)]<-0,
minimum = d[is.na(d)]<-min(d,na.rm = T),
"0.1" = d[is.na(d)]<-0.1*min(d,na.rm = T)
)
}
return(d)
}