# NOT RUN {
# }
# NOT RUN {
library("FRESA.CAD")
### Univariate Filter Examples ####
# Get the stage C prostate cancer data from the rpart package
data(stagec,package = "rpart")
# Prepare the data. Create a model matrix without the event time and interactions
stagec$pgtime <- NULL
stagec$eet <- as.factor(stagec$eet)
options(na.action = 'na.pass')
stagec_mat <- cbind(pgstat = stagec$pgstat,
as.data.frame(model.matrix(pgstat ~ .*.,stagec))[-1])
fnames <- colnames(stagec_mat)
fnames <- str_replace_all(fnames,":","__")
colnames(stagec_mat) <- fnames
# Impute the missing data
dataCancerImputed <- nearestNeighborImpute(stagec_mat)
dataCancerImputed[,1:ncol(dataCancerImputed)] <- sapply(dataCancerImputed,as.numeric)
# Get the top Features associated to pgstat
q_values <- univariate_Logit(data=dataCancerImputed,
Outcome="pgstat",
pvalue = 0.05)
qValueMatrix <- q_values
idiqValueMatrix <- q_values
barplot(-log(q_values),las=2,cex.names=0.4,ylab="-log(Q)",
main="Association with PGStat: IDI Test")
q_values <- univariate_Logit(data=dataCancerImputed,
Outcome="pgstat",
uniTest="zNRI",pvalue = 0.05)
qValueMatrix <- cbind(idiqValueMatrix,q_values[names(idiqValueMatrix)])
q_values <- univariate_residual(data=dataCancerImputed,
Outcome="pgstat",
pvalue = 0.05,type="LOGIT")
qValueMatrix <- cbind(qValueMatrix,q_values[names(idiqValueMatrix)])
q_values <- univariate_tstudent(data=dataCancerImputed,
Outcome="pgstat",
pvalue = 0.05)
qValueMatrix <- cbind(qValueMatrix,q_values[names(idiqValueMatrix)])
q_values <- univariate_Wilcoxon(data=dataCancerImputed,
Outcome="pgstat",
pvalue = 0.05)
qValueMatrix <- cbind(qValueMatrix,q_values[names(idiqValueMatrix)])
q_values <- univariate_correlation(data=dataCancerImputed,
Outcome="pgstat",
pvalue = 0.05)
qValueMatrix <- cbind(qValueMatrix,q_values[names(idiqValueMatrix)])
q_values <- univariate_correlation(data=dataCancerImputed,
Outcome="pgstat",
pvalue = 0.05,
method = "pearson")
#The qValueMatrix has the qValues of all filter methods.
qValueMatrix <- cbind(qValueMatrix,q_values[names(idiqValueMatrix)])
colnames(qValueMatrix) <- c("IDI","NRI","F","t","W","K","P")
#Do the log transform to display the heatmap
qValueMatrix <- -log10(qValueMatrix)
#the Heatmap of the q-values
gplots::heatmap.2(qValueMatrix,Rowv = FALSE,dendrogram = "col",
main = "Method q.values",cexRow = 0.4)
# }
Run the code above in your browser using DataLab