-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSumStats.R
More file actions
89 lines (54 loc) · 2.72 KB
/
SumStats.R
File metadata and controls
89 lines (54 loc) · 2.72 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
80
81
82
83
84
85
86
87
88
89
## SumStats.R ##
#' @export
#'
##############################################
## Author Information ##
# * Author: E.Frolli
# * Orginization: Univeristy of Texas Marine Science Institute
# * Contact: frolli.erin@utexas.edu
# * Date: 23 Jun 2017
##############################################
## The Code ##
SumStats <-function (qPCRData,E=NULL){
n = nrow(qPCRData) # Number of rows
L = ncol(qPCRData) # Number of col
##############################################################
# Warnings - make sure that they have all the corect values
##############################################################
# Efficency Vals
if (is.null(E)){
warning("No 'E' values for each gene. Will set Defalt to 2 or Effiency = ~ 100%.")
E = rep(2,L)
}
##############################################################
# Main Function
##############################################################
N = rep(n,L) # create the sample size vector
# create the Geometric mean vector
GeometricMean = round(apply(qPCRData,2,GeomMean),digits =2)
# create the Arithmatic mean vector
ArithmaticMean=round(apply(qPCRData,2,mean),digits =2)
# create the Minimum value vector
Min = round(apply(qPCRData,2,min),digits =2)
# create the Maximum value vector
Max = round(apply(qPCRData,2,max),digits =2)
# create the Average Deviation vector
AvDev = round(apply(qPCRData,2,AvrgDev),digits =2)
# Note use the Average Deviation after realize thats the value they used to create the "Standard Deviation"
# in there Table 1 in Pfaffl et al., this was also confermed by the BestKeeper Excel tool.
# create the coefficient of varience vector
CoVar = round((AvDev/ArithmaticMean*100),digits = 2)
# create the Minimum extream values of expression levels vector
Min2 = Min-GeometricMean
Min_Xfold = round(PowerF(E,Min2),digits=2) # Equation 1 in Pfaffl et al.
# create the Maximum extream values of expression levels vector
Max2 = Max-GeometricMean
Max_Xfold = round(PowerF(E,Max2),digits=2) # Equation 2 in Pfaffl et al.
# create the Sandard Deviation of the absolute regulation coefficients vector
AvDev_Xfold = round(PowerF(E,AvDev),digits=2) # In Table 1 and assumed to be equivilant to Equation 1 & 2 in Pfaffl et al.
# Combin all vectors into a Descriptive Statistics Table
SumStat = rbind(N,GeometricMean,ArithmaticMean,Min,Max,AvDev,CoVar,Min_Xfold,Max_Xfold,AvDev_Xfold)
colnames(SumStat) <- colnames(qPCRData)
# return qPCRData
return(SumStat)
}