-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTargetGenes.R
More file actions
79 lines (50 loc) · 2.12 KB
/
TargetGenes.R
File metadata and controls
79 lines (50 loc) · 2.12 KB
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
## TargetGenes.R ##
#' @export
#'
##############################################
## Author Information ##
# * Author: E.Frolli
# * Orginization: Univeristy of Texas Marine Science Institute
# * Contact: frolli.erin@utexas.edu
# * Date: 08 July 2017
##############################################
## The Code ##
TargetGenes <-function (TargetData,BKIndex,TargetE = NULL){
# require(Hmisc) # To run the corilation values
# Add the BestKeeper index to the TargetData to run Pearsons Corrilations
TargetData = cbind(TargetData,BKIndex)
n = nrow(TargetData) # Number of rows
L = ncol(TargetData) # Number of col
##############################################################
# Warnings - make sure that they have all the corect values
##############################################################
# Efficency Vals
if(!is.null(TargetE)){
TargetE = c(TargetE,2)
}
if (is.null(TargetE)){
warning("No 'TargetE' values for each gene. Will set Defalt to 2 or Effiency = ~ 100%.")
TargetE = rep(2,L)
}
# Are there Gene Symbol names - collumn names.
if (is.null(colnames(TargetData))){
stop("'TargetData' needs column names aka 'Gene Symbol' ")
}
##############################################################
# Main Function
##############################################################
# Calc the Descriptive Statistics of target genes
TD_SumStat = SumStats(TargetData,TargetE)
ParResult = rcorr(as.matrix(TargetData),type='pearson') # Corilation Result
CorVal = round(ParResult$r,digits = 3) # Seporate out the corilation values - will use to do our comparisons.
PVal = round(ParResult$P, digits = 3) # Seporate out the p-Values
# The above matxes have double values - eliminate them for less confusion but adding in a 0 or NA value.
for(i in 1:(L)){
CorVal[i,i:(L)]= NA
PVal[i,i:(L)]= NA
}
CorVal = as.table(CorVal)
PVal = as.table(PVal)
# return Data
return(list("TG.SummeryStats.Table"=TD_SumStat,"TG.Cor.Table"=CorVal,"TG.PVal.Table"=PVal))
}