Skip to content

Commit d232448

Browse files
committed
update PLSFC_class
add ci (equivalent to mlr for all components) BETA inherit fold_change class; allows use of existing plot fcns
1 parent e5bedc8 commit d232448

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Collate:
1717
'PCA_plotfcns.R'
1818
'PLSDA_class.R'
1919
'PLSDA_charts.R'
20+
'fold_change_class.R'
2021
'PLSFC_class.R'
2122
'PLSR_class.R'
2223
'autoscale_class.R'
@@ -30,7 +31,6 @@ Collate:
3031
'filter_na_count.R'
3132
'filter_smeta_class.R'
3233
'fisher_exact_class.R'
33-
'fold_change_class.R'
3434
'forward_selection_by_rank_class.R'
3535
'ggplot_theme_pub.R'
3636
'glog_class.R'

R/PLSFC_class.R

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
#' Partial least squares (PLS) fold change estimates
44
#' @export PLSFC
55
#' @importFrom pls plsr scores
6+
#' @include fold_change_class.R
67
PLSFC<-setClass(
78
"PLSFC",
8-
contains='method',
9+
contains='fold_change',
910
slots=c(
10-
params.factor_name='character',
11-
params.number_components='entity',
12-
params.control_group='character',
13-
outputs.fold_change='entity'
11+
params.number_components='entity'
1412
),
1513
prototype = list(name='Partial least squares discriminant analysis',
1614
type="classification",
@@ -52,6 +50,7 @@ setMethod(f="method.apply",
5250

5351
D$sample_meta[[M$factor_name]]=ordered(D$sample_meta[[M$factor_name]])
5452
BHAT=matrix(0,nrow=n,ncol=ncol(X))
53+
SE=BHAT
5554
# for all pairs of groups
5655
for (A in 1:(length(L)-1)) {
5756
for (B in (A+1):(length(L))) {
@@ -76,6 +75,7 @@ setMethod(f="method.apply",
7675
P=model.predict(P,S)
7776
sy=P$design_matrix[,1]
7877
sx=as.matrix(MC[2]$scores)
78+
7979
# get regression coefficients
8080
b=P$reg_coeff[,1]
8181
for (j in 1:ncol(sx)) {
@@ -92,6 +92,15 @@ setMethod(f="method.apply",
9292
Vx=as.matrix(MC[2]$loadings)
9393
bhat=t(bhat)%*%t(Vx)
9494

95+
# guestimate confidence intervals
96+
x=MC[1]$centred$data
97+
xhat=sy%*%(bhat)
98+
ssx=(x-xhat)^2
99+
ssx=apply(ssx,2,sum) # for each column of x
100+
ssy=sum(sy^2) # y_bar is zero by design
101+
SE[counter,]=(sqrt(ssx)/(sqrt(ssy)*sqrt((nrow(x)-2))))*qt(0.975,nrow(x)-2)*2
102+
103+
95104
BHAT[counter,]=bhat*2
96105

97106
counter=counter+1
@@ -102,12 +111,16 @@ setMethod(f="method.apply",
102111
}
103112

104113
FC=as.data.frame(t(BHAT))
105-
114+
SE=as.data.frame(t(SE))
106115
colnames(FC)=comp
116+
colnames(SE)=comp
107117

108118
rownames(FC)=colnames(D$data)
119+
rownames(SE)=colnames(D$data)
109120

110121
M$fold_change=2^FC
122+
M$upper_ci=2^(FC+SE)
123+
M$lower_ci=2^(FC-SE)
111124

112125
return(M)
113126
}

0 commit comments

Comments
 (0)