diff --git a/RdcRmodulesGrailsPlugin.groovy b/RdcRmodulesGrailsPlugin.groovy index 5e790813..15829b56 100644 --- a/RdcRmodulesGrailsPlugin.groovy +++ b/RdcRmodulesGrailsPlugin.groovy @@ -22,7 +22,7 @@ import org.transmartproject.core.users.User class RdcRmodulesGrailsPlugin { // the plugin version - def version = "16.2-SNAPSHOT" + def version = "16.2" // the version or versions of Grails the plugin is designed for def grailsVersion = "2.2.4 > *" // the other plugins this plugin depends on diff --git a/grails-app/conf/BuildConfig.groovy b/grails-app/conf/BuildConfig.groovy index aea6fe70..2bc2a195 100644 --- a/grails-app/conf/BuildConfig.groovy +++ b/grails-app/conf/BuildConfig.groovy @@ -62,7 +62,7 @@ grails.project.dependency.resolution = { /* serializable ImmutableMap only on guava 16 */ compile group: 'com.google.guava', name: 'guava', version: '16.0-dev-20140115-68c8348' - compile 'org.transmartproject:transmart-core-api:16.2-SNAPSHOT' + compile 'org.transmartproject:transmart-core-api:16.2' /* compile instead of test due to technical limitations * (referenced from resources.groovy) */ diff --git a/grails-app/controllers/com/recomdata/transmart/rmodules/AnalysisFilesController.groovy b/grails-app/controllers/com/recomdata/transmart/rmodules/AnalysisFilesController.groovy index 501783b1..3219719d 100644 --- a/grails-app/controllers/com/recomdata/transmart/rmodules/AnalysisFilesController.groovy +++ b/grails-app/controllers/com/recomdata/transmart/rmodules/AnalysisFilesController.groovy @@ -1,24 +1,19 @@ package com.recomdata.transmart.rmodules -import org.transmartproject.core.exceptions.InvalidRequestException - -import java.util.regex.Matcher -import java.util.regex.Pattern +import org.transmartproject.jobs.access.JobsAccessChecksService class AnalysisFilesController { - public static final String ROLE_ADMIN = 'ROLE_ADMIN' - def sendFileService - def springSecurityService - def RModulesOutputRenderService + JobsAccessChecksService jobsAccessChecksService + def download() { String jobName = params.analysisName - if (!checkPermissions(jobName)) { + if (!jobsAccessChecksService.canDownload(jobName)) { render status: 403 return } @@ -64,44 +59,7 @@ class AnalysisFilesController { sendFileService.sendFile servletContext, request, response, targetFile } - private boolean isAdmin() { - springSecurityService.principal.authorities.any { - it.authority == ROLE_ADMIN - } - } - private File getJobsDirectory() { new File(RModulesOutputRenderService.tempFolderDirectory) } - - private boolean checkPermissions(String jobName) { - String userName = extractUserFromJobName(jobName) - - def loggedInUser = springSecurityService.principal?.username - if (!loggedInUser) { - log.error 'Could not determine current logged in user\'s name' - return false - } - - if (userName == loggedInUser || admin) { - return true - } - - log.warn "User $loggedInUser has no access for job $jobName; refusing " + - "request for job $jobName" - false - } - - private String extractUserFromJobName(String jobName) { - Pattern pattern = ~/(.+)-[a-zA-Z]+-\d+/ - Matcher matcher = pattern.matcher(jobName) - - if (!matcher.matches()) { - //should never happen due to url mapping - throw new InvalidRequestException('Invalid job name') - } - - matcher.group(1) - } - } diff --git a/grails-app/services/org/transmartproject/jobs/access/JobsAccessChecksService.groovy b/grails-app/services/org/transmartproject/jobs/access/JobsAccessChecksService.groovy new file mode 100644 index 00000000..84367a3f --- /dev/null +++ b/grails-app/services/org/transmartproject/jobs/access/JobsAccessChecksService.groovy @@ -0,0 +1,51 @@ +package org.transmartproject.jobs.access + +import org.transmartproject.core.exceptions.InvalidRequestException + +import java.util.regex.Matcher +import java.util.regex.Pattern + +class JobsAccessChecksService { + + static transactional = false + + public static final String ROLE_ADMIN = 'ROLE_ADMIN' + + def springSecurityService + + boolean canDownload(String jobName) { + String userName = extractUserFromJobName(jobName) + + def loggedInUser = springSecurityService.principal?.username + if (!loggedInUser) { + log.error 'Could not determine current logged in user\'s name' + return false + } + + if (userName == loggedInUser || admin) { + return true + } + + log.warn "User $loggedInUser has no access for job $jobName; refusing " + + "request for job $jobName" + false + } + + private boolean isAdmin() { + springSecurityService.principal.authorities.any { + it.authority == ROLE_ADMIN + } + } + + private static String extractUserFromJobName(String jobName) { + Pattern pattern = ~/(.+)-[a-zA-Z]+-\d+/ + Matcher matcher = pattern.matcher(jobName) + + if (!matcher.matches()) { + //should never happen due to url mapping + throw new InvalidRequestException('Invalid job name') + } + + matcher.group(1) + } +} diff --git a/test/unit/com/recomdata/transmart/rmodules/AnalysisFilesControllerTests.groovy b/test/unit/com/recomdata/transmart/rmodules/AnalysisFilesControllerTests.groovy index 1b78c719..308f073c 100644 --- a/test/unit/com/recomdata/transmart/rmodules/AnalysisFilesControllerTests.groovy +++ b/test/unit/com/recomdata/transmart/rmodules/AnalysisFilesControllerTests.groovy @@ -7,6 +7,7 @@ import org.junit.After import org.junit.Before import org.junit.Test import org.transmartproject.core.exceptions.InvalidRequestException +import org.transmartproject.jobs.access.JobsAccessChecksService import javax.servlet.ServletContext import javax.servlet.http.HttpServletRequest @@ -19,18 +20,14 @@ import static org.hamcrest.Matchers.* @WithGMock class AnalysisFilesControllerTests { - private static final String USER_NAME = 'user' - private static final String OTHER_USER_NAME = 'other_user' - private static final String ADMIN_NAME = 'admin' private static final String EXISTING_FILE_NAME = 'file_that_exists' private static final String FILE_CONTENTS = 'file contents\n' - private static final String ANALYSIS_NAME = "$USER_NAME-Analysis-100" + private static final String ANALYSIS_NAME = "user-Analysis-100" File temporaryDirectory File analysisDirectory File targetFile def sendFileServiceMock - def mockGrailsUser @Before void before() { @@ -45,28 +42,11 @@ class AnalysisFilesControllerTests { sendFileServiceMock = mock() controller.sendFileService = sendFileServiceMock - mockGrailsUser = mock() - controller.springSecurityService = mock() - controller.springSecurityService.principal. - returns(mockGrailsUser).stub() + controller.jobsAccessChecksService = mock JobsAccessChecksService params.analysisName = ANALYSIS_NAME } - void setTestUsername(String username) { - mockGrailsUser.username.returns username - } - - void setAdmin(boolean value) { - if (value) { - def adminAuthority = mock() - adminAuthority.authority.returns AnalysisFilesController.ROLE_ADMIN - mockGrailsUser.authorities.returns([adminAuthority]) - } else { - mockGrailsUser.authorities.returns([]) - } - } - void setFile(String filename) { targetFile = new File(analysisDirectory, filename) targetFile << FILE_CONTENTS @@ -82,8 +62,8 @@ class AnalysisFilesControllerTests { @Test void basicTest() { // test the normal circumstances (file exists and is allowed) - testUsername = USER_NAME - file = EXISTING_FILE_NAME + controller.jobsAccessChecksService.canDownload(ANALYSIS_NAME).returns(true) + file = EXISTING_FILE_NAME sendFileServiceMock.sendFile(isA(ServletContext), isA(HttpServletRequest), isA(HttpServletResponse), @@ -98,8 +78,7 @@ class AnalysisFilesControllerTests { @Test void testNoPermission() { - testUsername = OTHER_USER_NAME - admin = false + controller.jobsAccessChecksService.canDownload(ANALYSIS_NAME).returns(false) play { controller.download() @@ -108,38 +87,10 @@ class AnalysisFilesControllerTests { assertThat response.status, is(403) } - @Test - void testAdminAlwaysHasPermission() { - testUsername = ADMIN_NAME - admin = true - file = EXISTING_FILE_NAME - - sendFileServiceMock.sendFile(isA(ServletContext), - isA(HttpServletRequest), isA(HttpServletResponse), - is(equalTo(targetFile))) - - play { - controller.download() - } - - assertThat response.status, is(200) - } - - @Test - void testBadAnalysisName() { - params.analysisName = 'not_a_valid_analysis_name' - - play { - shouldFail InvalidRequestException, { - controller.download() - } - } - } - @Test void testInexistingAnalysisName() { - testUsername = USER_NAME params.analysisName = ANALYSIS_NAME + '1' + controller.jobsAccessChecksService.canDownload(params.analysisName).returns(true) play { controller.download() @@ -150,19 +101,19 @@ class AnalysisFilesControllerTests { @Test void testAccessToExternalFilesNotAllowed() { - testUsername = USER_NAME - + controller.jobsAccessChecksService.canDownload(ANALYSIS_NAME).returns(true) file = '../test' + play { controller.download() } + assertThat response.status, is(404) } @Test void testNonExistingFile() { - testUsername = USER_NAME - + controller.jobsAccessChecksService.canDownload(ANALYSIS_NAME).returns(true) params.path = 'file_that_does_not_exist' play { diff --git a/test/unit/org/transmartproject/jobs/access/JobsAccessChecksServiceTests.groovy b/test/unit/org/transmartproject/jobs/access/JobsAccessChecksServiceTests.groovy new file mode 100644 index 00000000..ac0dcddb --- /dev/null +++ b/test/unit/org/transmartproject/jobs/access/JobsAccessChecksServiceTests.groovy @@ -0,0 +1,87 @@ +package org.transmartproject.jobs.access + +import grails.test.mixin.TestFor +import org.gmock.WithGMock +import org.junit.Before +import org.junit.Test +import org.transmartproject.core.exceptions.InvalidRequestException + +@TestFor(JobsAccessChecksService) +@WithGMock +class JobsAccessChecksServiceTests { + + @Test + void testOwnerCanReadData() { + testUsername = 'test_user' + admin = false + + play { + assertTrue service.canDownload('test_user-Analysis-100') + } + } + + @Test + void testOtherUserCanNotReadData() { + testUsername = 'other_user' + admin = false + + play { + assertFalse service.canDownload('test_user-Analysis-100') + } + } + + @Test + void testAdminCanReadData() { + testUsername = 'admin_user' + admin = true + + play { + assertTrue service.canDownload('test_user-Analysis-100') + } + } + + @Test + void testNotLoggedInUserCanNotReadData() { + service.springSecurityService = mock() + service.springSecurityService.principal.returns(null).stub() + + play { + assertFalse service.canDownload('test_user-Analysis-100') + } + } + + @Test + void testBadAnalysisName() { + testUsername = 'test_user' + admin = false + + play { + shouldFail InvalidRequestException, { + assertFalse service.canDownload('not_a_valid_analysis_name') + } + } + } + + def mockGrailsUser + + @Before + void before() { + mockGrailsUser = mock() + service.springSecurityService = mock() + service.springSecurityService.principal.returns(mockGrailsUser).stub() + } + + void setTestUsername(String username) { + mockGrailsUser.username.returns(username).stub() + } + + void setAdmin(boolean value) { + def authorities = [] + if (value) { + def adminAuthority = mock() + adminAuthority.authority.returns JobsAccessChecksService.ROLE_ADMIN + authorities.add(adminAuthority) + } + mockGrailsUser.authorities.returns(authorities).stub() + } +} diff --git a/web-app/Rscripts/Heatmap/HClusteredHeatmapLoader.R b/web-app/Rscripts/Heatmap/HClusteredHeatmapLoader.R index 66de9743..3c63e11c 100644 --- a/web-app/Rscripts/Heatmap/HClusteredHeatmapLoader.R +++ b/web-app/Rscripts/Heatmap/HClusteredHeatmapLoader.R @@ -124,8 +124,8 @@ zscore.file = "zscores.txt" sd_rows_mRNA<-apply (mRNAData,1,sd,na.rm=T) mRNAData<-mRNAData[!is.na(sd_rows_mRNA),] # remove markers where sd is NA sd_rows_mRNA<-sd_rows_mRNA[!is.na(sd_rows_mRNA)] - cutoff_sd<- sd_rows_mRNA[order(sd_rows_mRNA,decreasing = T)][maxDrawNumber+1] # filter by SD, draw only the top maxDrawNumber - mRNAData<-mRNAData[sd_rows_mRNA>cutoff_sd,] + indices_to_include <- order(sd_rows_mRNA, decreasing = T)[1:maxDrawNumber] # filter by SD, keep only the top maxDrawNumber + mRNAData <- mRNAData[indices_to_include, ] } colcolor<-colnames(mRNAData) # assign colors for different subset diff --git a/web-app/Rscripts/Heatmap/KMeansHeatmap.R b/web-app/Rscripts/Heatmap/KMeansHeatmap.R index c8684450..2368fa4f 100644 --- a/web-app/Rscripts/Heatmap/KMeansHeatmap.R +++ b/web-app/Rscripts/Heatmap/KMeansHeatmap.R @@ -115,8 +115,8 @@ zscore.file = "zscores.txt" sd_rows_matrix<-apply (matrixData,1,sd,na.rm=T) matrixData<-matrixData[!is.na(sd_rows_matrix),] # remove markers where sd is NA sd_rows_matrix<-sd_rows_matrix[!is.na(sd_rows_matrix)] - cutoff_sd<- sd_rows_matrix[order(sd_rows_matrix,decreasing = T)][maxDrawNumber+1] # filter by SD, draw only the top maxDrawNumber - matrixData<-matrixData[sd_rows_matrix>cutoff_sd,] + indices_to_include <- order(sd_rows_matrix, decreasing = T)[1:maxDrawNumber] # filter by SD, keep only the top maxDrawNumber + matrixData <- matrixData[indices_to_include, ] } #Transpose the matrix to put the sample column into a row. diff --git a/web-app/Rscripts/Manhattan/Manhattan.R b/web-app/Rscripts/Manhattan/Manhattan.R new file mode 100644 index 00000000..2db26866 --- /dev/null +++ b/web-app/Rscripts/Manhattan/Manhattan.R @@ -0,0 +1,180 @@ +args = commandArgs(trailingOnly=TRUE) +library(Cairo) + +threshold<-5e-8 +maximumPeaks<-1 +chr_X<-"23" +chr_Y<-"24" +chr_M<-"25" +chr_X_str<-"X" +chr_Y_str<-"Y" +chr_M_str<-"M" +points_shape<-19 +annotationSize<-1 +imgWidth<-1000 +imgHeight<-800 +peaks<-NULL + +create.manhattan.plot <- function(inputFile=inputFile,studyFileName=NULL, studyName=NULL) { + png(file=paste("manhattan",".png",sep=""),width=imgWidth,height=imgHeight, type="cairo") + res<-read.table(inputFile, header=TRUE, sep="\t") + + plotTitle <- "Manhattan Plot" + + if (!is.null(studyFileName)){ + plotTitle <- paste(as.character(read.table(studyFileName, sep="\t", header=TRUE)$STUDY_NAME[1]),"-", plotTitle, sep =" ") + } + if (!is.null(studyName)){ + plotTitle <- paste(studyName,"-", plotTitle, sep =" ") + } + + res<-res[which(!is.na(res$chrom)),] # remove data where chrom is null + + pvalue<-as.vector(res$pvalue) + chr <-as.vector(res$chrom) + pos<-as.vector(res$pos) + annots<-as.vector(res$gene) + + allChr <- unique(res$chrom) + + # get one peak per chromosome + for(c in allChr) { + + c_res<-res[which(res$pvalue maximumPeaks) { + c_res<-c_res[1:maximumPeaks,] + } + + if (is.null(peaks)) { + peaks = c_res + } + else { + peaks<-rbind(peaks,c_res) + } + + + } + + # for computing purpose replace X,Y,M chrom with numbers + if (length(which(chr==chr_X_str)) > 0) { + chr[which(chr==chr_X_str)]<-chr_X + } + if (length(which(chr==chr_Y_str)) > 0) { + chr[which(chr==chr_Y_str)]<-chr_Y + } + if (length(which(chr==chr_M_str)) > 0) { + chr[which(chr==chr_M_str)]<-chr_M + } + + res$chrom<-as.numeric(chr) + res<-res[order(as.numeric(res$chrom), res$pos),] + + MakingManhattan23andMeStyleFanciestAlt3(res$pvalue, res$chrom, res$pos, res$gene, maintext=plotTitle, peaks=peaks) + dev.off() +} + +MakingManhattan23andMeStyleFanciestAlt3 <- function(pee,chr,pos,annots,backannots=NULL,upper.limit=NULL,peak.flag=NULL,maintext=NULL,shiftups=NULL,shiftdowns=NULL, peaks=NULL) { + + annots <- as.character(annots); + chr.limits <- aggregate(pos,by=list(chr),FUN=max,na.rm=T) + numchr <- dim(chr.limits)[1]; + row.names(chr.limits) <- chr.limits$Group.1; + + evenses <- seq(2,numchr,2); + odds <- seq(1,numchr,2); + neven <- length(evenses); + evencols <- rainbow(neven); + revenses <- c(seq(ceiling(neven/2),neven,1),seq(1,ceiling(neven/2)-1,1)); + + nodd <- length(odds); + oddcols <- rainbow(nodd); + + thosecols <- rep(NA,times=numchr); + + thosecols[evenses] <- "#6bcedd"; #"#b0e0b0"; + thosecols[odds] <- "#3955a6"; #"#b0b0e0"; + + uppercol <- "red"; + + inap <- is.na(pee) | !is.finite(pee); + upperbound <- ceiling(0.25 + min(upper.limit,max(-log10(pee[!inap]))+2) ); + + if (upperbound < 16) { + upperbound <- 16; + } + + peaksChr<-as.integer(as.vector(peaks$chrom)) + peaksPos<-as.vector(peaks$pos) + chrAxisLabel<-as.character(seq(1,numchr,1)) + + chrAxisLabel[which(chrAxisLabel==chr_X)]<-chr_X_str + chrAxisLabel[which(chrAxisLabel==chr_Y)]<-chr_Y_str + chrAxisLabel[which(chrAxisLabel==chr_M)]<-chr_M_str + + plot(chr+pos/(1+chr.limits[as.character(chr),"x"]),c(0,rep(upperbound,times=length(pos)-1)),xlab="Chromosome",ylab="-log10(pval)",main=maintext,yaxp=c(0,upperbound,upperbound),type="n",xaxt="n",bty="l", ylim=c(0,upperbound)) + axis(side=1,at=seq(1,numchr,1)+0.5,labels=chrAxisLabel); + points(chr+pos/(1+chr.limits[as.character(chr),"x"]),-log10(pee),col=thosecols[chr],lwd=2, pch=points_shape); + + limt <- -log10(threshold) + + iio <- -log10(pee) > limt + + points((chr+pos/(1+chr.limits[as.character(chr),"x"]))[iio],-log10(pee)[iio],col=thosecols[chr][iio],lwd=2, pch=points_shape) + if (length(peaksPos) > 0) { + text(peaksChr+peaksPos/(1+chr.limits[as.character(peaksChr),"x"]),-log10(peaks$pvalue)+(upperbound/40),labels=peaks$gene, cex=annotationSize, adj=0) + } + + abline(h=-log10(threshold),col="red") + + if (!is.null(peak.flag)) { + + peaks <- data.frame(cbind(pee=as.numeric(pee[peak.flag]),chr=chr[peak.flag],pos=pos[peak.flag])); + peaks$annots <- as.character(annots)[peak.flag]; + #otherwise co-erce number types to factors or chars + + if (!is.null(backannots)) { + peaks$backannots <- as.character(backannots)[peak.flag]; + } + + peaks$over <- (peaks$pee < 10^(-1*upper.limit)) + + + shifts <- rep(0,times=length(peaks$pee)); + + if(!is.null(shiftups)) { + shifts[shiftups] <- 0.5; + } + + if(!is.null(shiftdowns)) { + shifts[shiftdowns] <- -0.5; + } + + bigverts2 <- ifelse(-log10(peaks$pee) > upper.limit,upper.limit+0.5,-log10(peaks$pee)+ 0.5 + shifts); + + io <- peaks$over; + iunder <- peaks$pee < 5.0e-08 + coltxt <- rep("black",times=dim(peaks)[1]) + coltxt[io] <- "blue"; + coltxt[!iunder] <- "black" + + iempty <- peaks$annots == "[]"; + if (!is.null(backannots)) { + peaks$annots[iempty] <- peaks$backannots[iempty]; + } + + if (dim(peaks)[1]>0){ + text(peaks$chr+peaks$pos/(1+chr.limits[as.character(peaks$chr),"x"]),bigverts2,peaks$annots,col=coltxt,font=2,cex=1.2); + } + + + if(sum(io) > 0) { + text(peaks$chr[io]+peaks$pos[io]/(1+chr.limits[as.character(peaks$chr[io]),"x"]),bigverts2[io]+1,paste("peak p:",format(peaks$pee[io],digits=2),sep=""),col="blue"); + } + } + + +} + diff --git a/web-app/Rscripts/PCA/LoadPCA.R b/web-app/Rscripts/PCA/LoadPCA.R index 6558fff8..bebf5bf1 100644 --- a/web-app/Rscripts/PCA/LoadPCA.R +++ b/web-app/Rscripts/PCA/LoadPCA.R @@ -34,8 +34,8 @@ zscore.file = "zscores.txt" library(reshape2) library(Cairo) - library(ggplot2) - library(plyr) + library(ggplot2) + library(plyr) #Prepare the package to capture the image file. CairoPNG(file=paste("PCA.png",sep=""),width=400,height=400) @@ -69,7 +69,7 @@ zscore.file = "zscores.txt" mRNAData$PROBE.ID <- gsub("^\\s+|\\s+$", "",mRNAData$PROBE.ID) mRNAData$GENE_SYMBOL <- gsub("^\\s+|\\s+$", "",mRNAData$GENE_SYMBOL) mRNAData$PATIENT.ID <- gsub("^\\s+|\\s+$", "",mRNAData$PATIENT.ID) - mRNAData$SUBSET <- gsub("^\\s+|\\s+$", "",mRNAData$SUBSET) + mRNAData$SUBSET <- gsub("^\\s+|\\s+$", "",mRNAData$SUBSET) # The PROBE.ID column needs to have the values from GENE_SYMBOL concatenated as a suffix, # but only if the latter does not contain a private value (which means that the biomarker was not present in any of the dictionaries) @@ -77,8 +77,8 @@ zscore.file = "zscores.txt" rowsToConcatenate <- grep("^PRIVATE", mRNAData$GENE_SYMBOL, invert = TRUE) mRNAData$PROBE.ID[rowsToConcatenate] <- paste(mRNAData$PROBE.ID[rowsToConcatenate], mRNAData$GENE_SYMBOL[rowsToConcatenate],sep="_") mRNAData$PROBE.ID <- as.factor(mRNAData$PROBE.ID) - groupValues <- levels(mRNAData$PROBE.ID) - mRNAData$PROBE.ID <- paste("X",as.numeric(mRNAData$PROBE.ID),sep="") + groupValues <- levels(mRNAData$PROBE.ID) + mRNAData$PROBE.ID <- paste("X",as.numeric(mRNAData$PROBE.ID),sep="") #Grab only the columns we need for doing the melt/cast. mRNAData <- mRNAData[c('PATIENT.ID','VALUE','PROBE.ID')] @@ -164,12 +164,15 @@ zscore.file = "zscores.txt" title(xlab = "Component") dev.off() - + + max.toplot = min(3,numberOfComponents) #Creates the plot of observations scores <- as.data.frame(pca.results$x) scores[,"subset"] <- sub("S2", "Subset 2", sub("S1", "Subset 1", substr(rownames(scores),0,2))) for (i in 1:2){ - for(j in (i+1):3){ + if(i < max.toplot) { + for(j in (i+1):max.toplot){ + print(sprintf("observations plot %d v %d", i, j)) tmp <- ggplot(data=scores, aes_string(x=paste("PC", i, sep=""), y=paste("PC", j, sep=""))) tmp <- tmp +geom_hline(yintercept=0, colour="gray65") tmp <- tmp +geom_vline(xintercept=0, colour="gray65") @@ -180,11 +183,14 @@ zscore.file = "zscores.txt" print (tmp) dev.off() } + } } #Creates the circle of correlations for (i in 1:2){ - for(j in (i+1):3){ + if (i < max.toplot) { + for(j in (i+1):max.toplot){ + print(sprintf("circle plot %d v %d", i, j)) corcir=circle(c(0,0), npoints=100) correlations=as.data.frame(cor(mRNAData, pca.results$x)) arrows=data.frame(genes=rownames(correlations), x1=rep(0, length(pca.results$center)), y1=rep(0,length(pca.results$center)), x2=correlations[,paste("PC", i, sep="")], y2=correlations[,paste("PC", j, sep="")]) @@ -203,6 +209,7 @@ zscore.file = "zscores.txt" print (tmp) dev.off() } + } } } diff --git a/web-app/Rscripts/QQ/QQPlot.R b/web-app/Rscripts/QQ/QQPlot.R index 849b27f1..bc55fdaa 100644 --- a/web-app/Rscripts/QQ/QQPlot.R +++ b/web-app/Rscripts/QQ/QQPlot.R @@ -43,7 +43,7 @@ create.qq.plot.single<-function(qqData, df=2){ #Remove the log scale from the p-value. #qqData$p.no.log<-10^-(qqData$pvalue) - print(qqData) +## print(qqData) #Compute the chi square value. qqData$chi.sq<-qchisq(qqData$pvalue, df=df, log.p=F, lower.tail=F) diff --git a/web-app/Rscripts/aCGH/acgh-frequency-plot.R b/web-app/Rscripts/aCGH/acgh-frequency-plot.R index 1f4f30e6..aa6d92dd 100644 --- a/web-app/Rscripts/aCGH/acgh-frequency-plot.R +++ b/web-app/Rscripts/aCGH/acgh-frequency-plot.R @@ -136,7 +136,7 @@ freqPlot_qdnaseq <- function (column, groupnames, phenodata, calls, data.info){ acgh.frequency.plot <- function ( column = 'group') { - library(reshape) + library(reshape2) library(Cairo) # read the data diff --git a/web-app/js/plugin/HClust.js b/web-app/js/plugin/HClust.js index 585fadfa..6d60ed78 100644 --- a/web-app/js/plugin/HClust.js +++ b/web-app/js/plugin/HClust.js @@ -20,14 +20,31 @@ HierarchicalClusteringView.prototype.constructor = HierarchicalClusteringView; // submit analysis job HierarchicalClusteringView.prototype.submit_job = function () { + var job = this; - // get formParams - var formParams = this.get_form_params(); + var actualSubmit = function() { + // get formParams + var formParams = job.get_form_params(); - if (formParams) { // if formParams is not null - submitJob(formParams); + if (formParams) { // if formParams is not null + submitJob(formParams); + } } + // Check whether we have the node details for the HD node already + // If not, we should fetch them first + if (typeof GLOBAL.HighDimDataType !== "undefined" && GLOBAL.HighDimDataType) { + actualSubmit(); + } else { + var divId = 'divIndependentVariable'; + runAllQueriesForSubsetId(function () { + highDimensionalData.fetchNodeDetails(divId, function( result ) { + highDimensionalData.data = JSON.parse(result.responseText); + highDimensionalData.populate_data(); + actualSubmit(); + }); + }, divId); + } } diff --git a/web-app/js/plugin/KClust.js b/web-app/js/plugin/KClust.js index 339dcd19..67bb6c11 100644 --- a/web-app/js/plugin/KClust.js +++ b/web-app/js/plugin/KClust.js @@ -22,11 +22,30 @@ KMeansClusteringView.prototype.constructor = KMeansClusteringView; // submit analysis job KMeansClusteringView.prototype.submit_job = function () { - // get formParams - var formParams = this.get_form_params(); + var job = this; - if (formParams) { // if formParams is not null - submitJob(formParams); + var actualSubmit = function() { + // get formParams + var formParams = job.get_form_params(); + + if (formParams) { // if formParams is not null + submitJob(formParams); + } + } + + // Check whether we have the node details for the HD node already + // If not, we should fetch them first + if (typeof GLOBAL.HighDimDataType !== "undefined" && GLOBAL.HighDimDataType) { + actualSubmit(); + } else { + var divId = 'divIndependentVariable'; + runAllQueriesForSubsetId(function () { + highDimensionalData.fetchNodeDetails(divId, function( result ) { + highDimensionalData.data = JSON.parse(result.responseText); + highDimensionalData.populate_data(); + actualSubmit(); + }); + }, divId); } } diff --git a/web-app/js/plugin/PCA.js b/web-app/js/plugin/PCA.js index 73fe0735..41a4cad6 100644 --- a/web-app/js/plugin/PCA.js +++ b/web-app/js/plugin/PCA.js @@ -21,12 +21,30 @@ PCAView.prototype.constructor = PCAView; // submit analysis job PCAView.prototype.submit_job = function () { + var job = this; - // get formParams - var formParams = this.get_form_params(); + var actualSubmit = function() { + // get formParams + var formParams = job.get_form_params(); - if (formParams) { // if formParams is not null - submitJob(formParams); + if (formParams) { // if formParams is not null + submitJob(formParams); + } + } + + // Check whether we have the node details for the HD node already + // If not, we should fetch them first + if (typeof GLOBAL.HighDimDataType !== "undefined" && GLOBAL.HighDimDataType) { + actualSubmit(); + } else { + var divId = 'divIndependentVariable'; + runAllQueriesForSubsetId(function () { + highDimensionalData.fetchNodeDetails(divId, function( result ) { + highDimensionalData.data = JSON.parse(result.responseText); + highDimensionalData.populate_data(); + actualSubmit(); + }); + }, divId); } }