diff --git a/R/annotSheet.R b/R/annotSheet.R deleted file mode 100644 index a400764..0000000 --- a/R/annotSheet.R +++ /dev/null @@ -1,18 +0,0 @@ -#' annotSheet -#' @export - - -annotSheet <- -function(annot_all) { - # put accurate m/z into list - annot_all$`Accurate m/z` <- lapply(apply(annot_all$`Accurate m/z`,1, function(x){return(list(x))}),function(x){return(matrix(x[[1]],ncol=3))}) - # Caluclate number of columns in sheet - bins <- length(annot_all[[1]]) - # Build table for each bin - annot_info <- list() - for (i in 1:bins){ - annot_info[[i]] <- makeTable(lapply(annot_all,function(x,y){return(x[[y]])},y=i)) - } - annot_info <- do.call(rbind,annot_info) - return(annot_info) -} diff --git a/R/annotateFIE.R b/R/annotateFIE.R deleted file mode 100644 index 11e11af..0000000 --- a/R/annotateFIE.R +++ /dev/null @@ -1,29 +0,0 @@ -#' Annotation of FIE-HRMS m/z -#' -#' @param explan_mass -#' @param data -#' @param peaks -#' @param mode -#' @param ppm -#' @param gencors -#' @param genmf -#' @param genpip -#' @param lat -#' @export - -annotateFIE <- -function(explan_mass,data,peaks,mode,ppm,gencors=T,genmf=T,genpip=T,lat=list(c(C=0,iC=0,H=0,iH=0,N=0,iN=0,O=0,iO=0,F=0,Na=0,Si=0,P=0,S=0,Cl=0,iCl=0,Br=0,iBr=0,K=0,iK=0),c(C=90,iC=1,H=180,iH=0,N=10,iN=0,O=40,F=0,Na=1,Si=0,P=6,S=5,Cl=0,iCl=0,Br=0,iBr=0,K=1,iK=1,iO=1))){ - annot_all <- list() - annot_all[["Accurate m/z"]] <- cbind(Bin=rownames(explan_mass),explan_mass) - if(gencors==T){ - annot_all[["Correlation Analysis"]] <- corAnalysis(data,rownames(explan_mass),mode=mode) - } - if(genmf==T){ - annot_all[["Molecular Formulas"]] <- apply(explan_mass,1,getMF,mode=mode,lat=lat,ppm=ppm) - annot_all["Theoretical Isotope Distributions"] <- list(lapply(annot_all$'Molecular Formulas',getIsoDist,mode=mode)) - } - if(genpip==T){ - annot_all["Putative Ionisation Products"] <- list(lapply(explan_mass[,1],getPIP,mode=mode,ppm=ppm)) - } - return(annot_all) -} diff --git a/R/annotateLC.R b/R/annotateLC.R deleted file mode 100644 index b9a1e9e..0000000 --- a/R/annotateLC.R +++ /dev/null @@ -1,17 +0,0 @@ -#' LC annotation -#' @export - -annotateLC <- function(features,data,xset,mode,ppm){ - peakTab <- peakTable(xset) - mz.id <- round(peakTab$mz, digits=2) - rt.id <- round(peakTab$rt/60, digits=2) - f.id <- paste(mode,"M",mz.id,"T",rt.id,sep="") - feat.ind <- which(f.id %in% features) - featTab <- data.frame(ID=f.id[feat.ind],peakTab[feat.ind,]) - cat('\nRunning Correlation Analysis\n') - corrAnalysis <- corAnalysisLC(data,features,mode) - cat('\nRunning PIP searches\n\n') - featPIP <- lapply(featTab$mz,getPIP,mode=mode,ppm=ppm) - names(featPIP) <- featTab$ID - return(list(featPIP=featPIP,corAnalysis=corrAnalysis,peakTable=data.frame(ID=f.id,peakTab[,1:6]))) -} diff --git a/R/calcDiff.R b/R/calcDiff.R index 1e439aa..cb28bdf 100644 --- a/R/calcDiff.R +++ b/R/calcDiff.R @@ -2,7 +2,6 @@ #' #' @param mat #' @param mo -#' @export calcDiff <- function(mat,mo){ diff --git a/R/corAnalysisLC.R b/R/corAnalysisLC.R deleted file mode 100644 index cc43774..0000000 --- a/R/corAnalysisLC.R +++ /dev/null @@ -1,43 +0,0 @@ -#' corAnalysisLC -#' @export - -corAnalysisLC <- function(data,varlist,mode,pval=0.05){ - cors <- rcorr(as.matrix(data)) - cors$P <- apply(cors$P,1,p.adjust,method="bonferroni") - cors$r[cors$P>pval] <- 0 - cors$r[cors$r==1] <- 0 - cors$r[cors$r < 0] <- 0 - cors <- cors$r - cors <- cors[,colnames(cors) %in% varlist] - s <- apply(cors,1,sum) - cors <- cors[s>0,] - cors.lists <- corLists(cors) - cor.names <- sapply(cors.lists,function(x){return(colnames(x)[1])}) - names(cors.lists) <- cor.names - cors.lists <- lapply(cors.lists,function(x){ - rt <- strsplit(as.character(x[,1]),'T') - rt <- as.numeric(sapply(rt,function(x){return(x[2])})) - mz <- strsplit(as.character(x[,1]),'T') - mz <- sapply(mz,function(x){return(x[1])}) - mz <- as.numeric(gsub(paste(mode,'M',sep=''),'',mz)) - return(data.frame(x,mz=mz,rt=rt)) - }) - cors.diff <- lapply(names(cors.lists),function(x,l,m){ - l <- l[[x]] - l[,1] <- l$mz - l <- l[,1:2] - mz <- strsplit(colnames(l)[1],'T') - mz <- sapply(mz,function(y){return(y[1])}) - mz <- gsub('M','',mz) - colnames(l)[1] <- mz - return(l) - },l=cors.lists,m=mode) - cors.diff <- lapply(cors.diff,calcDiff,mo=mode) - cors.lists <- lapply(1:length(cors.lists),function(x,l,d){ - l <- l[[x]] - d <- d[[x]] - return(data.frame(l,d[,3:5])) - },l=cors.lists,d <- cors.diff) - names(cors.lists) <- cor.names - return(cors.lists) -} \ No newline at end of file diff --git a/R/corLists.R b/R/corLists.R index 4c11190..6b49b4a 100644 --- a/R/corLists.R +++ b/R/corLists.R @@ -1,7 +1,6 @@ #' Aggregate significant correlations into lists for each variable #' #' @param x -#' @export corLists <- function(x) { diff --git a/R/filterIso.R b/R/filterIso.R deleted file mode 100644 index 9dad6a0..0000000 --- a/R/filterIso.R +++ /dev/null @@ -1,19 +0,0 @@ -#' filterIso -#' @export - -filterIso<- -function(isos){ - for (i in 1:length(isos)){ - curr.iso <- isos[[i]] - iso.mat <- matrix(nrow=0,ncol=4) - for(x in 1:nrow(curr.iso)){ - iso <- curr.iso[x,4] - iso <- unlist(strsplit(iso," ")) - if (length(iso) < 3){ - iso.mat <- rbind(iso.mat,curr.iso[x,]) - } - } - isos[[i]] <- iso.mat - } - return(isos) -} diff --git a/R/filterMF.R b/R/filterMF.R deleted file mode 100644 index a1eff0d..0000000 --- a/R/filterMF.R +++ /dev/null @@ -1,30 +0,0 @@ -#' Filter generated MFs -#' -#' @param MFs -#' -#' @description Filter MFs that have more than one adduct or more than one isotope. -#' @export - -filterMF <- -function(MFs){ - mf <- as.character(MFs[,"Clean MF"]) - mf <- sapply(mf,function(x){y <- strsplit(x,"[.]");return(y)}) - mf <- lapply(mf,function(x){y <- sapply(x,gsub,pattern="iCl",replacement="ICL");return(y)}) - mf <- lapply(mf,function(x){y <- sapply(x,gsub,pattern="iO",replacement="Io");return(y)}) - mf <- lapply(mf,function(x){y <- sapply(x,gsub,pattern="iK",replacement="Ik");return(y)}) - mf <- unlist(lapply(mf,function(x){y <- !(TRUE %in% (grepl("iC",x) & grepl("Ik",x) || - grepl("iC",x) & grepl("Io",x) || - grepl("iC",x) & grepl("ICL",x) || - grepl("Io",x) & grepl("ICL",x) || - grepl("Io",x) & grepl("Ik",x) || - grepl("K",x) & grepl("Na",x) || - grepl("Na",x) & grepl("Ik",x) || - grepl("K",x) & grepl("Cl",x) || - grepl("ICL",x) & grepl("K",x) || - grepl("K",x) & grepl("Ik",x) || - grepl("Cl",x) & grepl("ICL",x)));return(y)})) - filtered.mfs <- MFs[which(mf==T),] - filtered.mfs <- matrix(filtered.mfs,ncol=6) - colnames(filtered.mfs) <- colnames(MFs) - return (filtered.mfs) -} diff --git a/R/filterPIP.R b/R/filterPIP.R deleted file mode 100644 index f4b59cf..0000000 --- a/R/filterPIP.R +++ /dev/null @@ -1,16 +0,0 @@ -#' filterPIP -#' @export - -filterPIP <- - function(res){ - patterns <- c("ic acid","keto","","","(R)-","(S)-","-L-","L-","(+)-", - "cis,","cis-","trans-","β-","-D-", - "D-","D.","γ-","-n-","N-","α-","α","β") - replacements <- c("ate","oxo","","","","","","","","","","","","","","","","","","","","") - for(i in 1:length(patterns)){ - res[,2] <- sapply(res[,2],gsub,pattern=patterns[i],replacement=replacements[i],fixed=TRUE) - } - res[,2] <- tolower(res[,2]) - res <- res[!duplicated(res[,2]),] - return(res) - } \ No newline at end of file diff --git a/R/getIsoDist.R b/R/getIsoDist.R deleted file mode 100644 index e832c71..0000000 --- a/R/getIsoDist.R +++ /dev/null @@ -1,23 +0,0 @@ -#' getIsoDist -#' @export - -getIsoDist <- function(mf_res,mode){ - if(nrow(mf_res)>0){ - if (mode=="p"){ - charge <- 1 - } - if (mode=="n"){ - charge <- -1 - } - iso <- grepl("i",mf_res[,"Clean.MF"],fixed=TRUE) - if(length(which(iso==T))>0){ - mf_res <- mf_res[-which(iso==T),] - } - if(nrow(mf_res)>0){ - iso_ab <- lapply(as.character(mf_res[,"MF"]),isoDistr,chrg=charge) - iso_ab <- filterIso(iso_ab) - names(iso_ab) <- mf_res[,"MF"] - return(iso_ab) - } - } -} \ No newline at end of file diff --git a/R/makeTable.R b/R/makeTable.R deleted file mode 100644 index e9a8354..0000000 --- a/R/makeTable.R +++ /dev/null @@ -1,75 +0,0 @@ -#' makeTable -#' @export - -makeTable <- - function(annot_info){ - # combine iso and mf tables if present - MF.iso <- list() - if("Molecular Formulas" %in% names(annot_info) & "Theoretical Isotope Distributions" %in% names(annot_info)){ - if (nrow(annot_info[["Molecular Formulas"]])>0 & !is.null(annot_info[["Theoretical Isotope Distributions"]])){ - MF.tab <- annot_info[["Molecular Formulas"]] - MF.tab <- matrix(apply(MF.tab,2,as.character),ncol=ncol(MF.tab)) - colnames(MF.tab) <- colnames(annot_info[["Molecular Formulas"]]) - Iso.tab <- annot_info[["Theoretical Isotope Distributions"]] - for (i in 1:nrow(MF.tab)){ - if(MF.tab[i,3] %in% names(Iso.tab)){ - iso.cur <- Iso.tab[[which(names(Iso.tab)==MF.tab[i,3])]] - } else { - iso.cur <- matrix(ncol=4,nrow=1) - } - colnames(iso.cur) <- c("m.z.1","Prob","rel.Int","Isotope") - MF.tab.cur <- matrix(ncol=ncol(MF.tab),nrow=nrow(iso.cur)-1) - colnames(MF.tab.cur) <- colnames(MF.tab) - MF.tab.cur <- rbind(as.character(MF.tab[i,]),MF.tab.cur) - MF.iso.tab <- cbind(MF.tab.cur,iso.cur) - MF.iso[[i]] <- MF.iso.tab - } - MF.iso <- ldply(MF.iso,data.frame,stringsAsFactors=F) - MF.iso <- apply(MF.iso,2,as.character) - annot_info$`Molecular Formulas` <- MF.iso - annot_info <- annot_info[-which(names(annot_info) == "Theoretical Isotope Distributions")] - } else { - if (nrow(annot_info[["Molecular Formulas"]])>0){ - MF.iso <- cbind(annot_info[["Molecular Formulas"]],matrix(ncol=4,nrow=nrow(annot_info[["Molecular Formulas"]]))) - } else { - MF.iso <- matrix(ncol=10,nrow=1) - } - annot_info$`Molecular Formulas` <- MF.iso - annot_info <- annot_info[-which(names(annot_info) == "Theoretical Isotope Distributions")] - } - } - # rename columns for each table - for (i in names(annot_info)){ - if (i == "Accurate m/z"){ - colnames(annot_info[[i]]) <- c("Bin","Accurate Mass","Intensity") - } - if (i == "Correlation Analysis"){ - colnames(annot_info[[i]]) <- c("m/z","Coefficient","Difference","Relation_to","Relation_from") - } - if (i == "Molecular Formulas"){ - colnames(annot_info[[i]]) <- c( "m/z","Original MF","Clean MF","Theoretical m/z","RDB", - "PPM Error","m/z","Probability","Relative Intensity","Isotope") - } - if (i == "Putative Ionisation Product"){ - colnames(annot_info[[i]]) <- c("m/z","Theoretical m/z","MF","Name","Adduct","PPM Error") - } - } - # calculate number of rows needed for table - row <- list() - for (i in 1:length(annot_info)){ - row[[i]] <- dim(annot_info[[i]])[1] - } - names(row) <- names(annot_info) - row <- max(unlist(row)) - # expand each table to the max row number - annot_info <- lapply(annot_info, function(x,row){ - row.add <- row - nrow(x) - new.tab <- matrix(ncol=ncol(x),nrow=row.add) - colnames(new.tab) <- colnames(x) - new.tab <- rbind(x,new.tab) - return(new.tab) - },row=row) - # combine each table - annot_table <- do.call("cbind", annot_info) - return(annot_table) - } \ No newline at end of file diff --git a/R/viewAnnotation.R b/R/viewAnnotation.R deleted file mode 100644 index 487757d..0000000 --- a/R/viewAnnotation.R +++ /dev/null @@ -1,197 +0,0 @@ -#' View annotation output -#' @name viewAnnotation -#' @description A shiny app to view the RData output of the annotateFIE function -#' @author Jasen Finch -#' @export -#' -viewAnnotation <- function(){ - options(shiny.maxRequestSize = 20*1024^2) - options(digits=10) - shinyApp( - ui = fluidPage( - titlePanel("viewAnnotation"), - sidebarLayout( - sidebarPanel( - fileInput('file1', 'Upload Annotation:', - accept = c( - '.RData' - ) - ), - tags$hr(), - radioButtons('mode', 'Mode', - c(Positive='Positive_Mode', - Negative='Negative_Mode')), - uiOutput("mz"), - tags$hr(), - textInput("boxplots","Box Plot Folder Path:"), - textInput("binplots","Bin Plot Folder Path:") - ), - mainPanel( - tabsetPanel( - tabPanel("Accurate m/z", dataTableOutput('accurate')), - tabPanel("Box Plots", imageOutput('boxplot')), - tabPanel("Bin Plots", imageOutput('binplot')), - tabPanel("Correlation Analysis", dataTableOutput('correlation')), - tabPanel("Molecular Formulas",dataTableOutput('MF')), - tabPanel("Theoretical Isotope Distributions", - fluidRow(uiOutput("selectMF")), - fluidRow(tableOutput('IsoDist')), - fluidRow(plotOutput('isoplot')) - ), - tabPanel("Putative Ionisation Products", - fluidRow(dataTableOutput('PIP')) - ), - tabPanel("PIP Structures", - fluidRow(uiOutput("selectPIP")), - plotOutput('smile') - ) - ) - ) - ) - ), - - server = function(input, output) { - loadData <- reactive({ - if(is.null(input$file1)) return(NULL) - load(input$file1$datapath) - annot.res - }) - availmz <- reactive({ - if(is.null(loadData())) return(NULL) - annot.res <- loadData() - annot.res[[input$mode]][["Accurate m/z"]][,1] - }) - availMF <- reactive({ - if(is.null(loadData())) return(NULL) - annot.res <- loadData() - names(annot.res[[input$mode]][["Theoretical Isotope Distributions"]][[input$selectedmz]]) - }) - availPIP <- reactive({ - if(is.null(loadData())) return(NULL) - annot.res <- loadData() - annot.res <- annot.res[[input$mode]][["Putative Ionisation Products"]][[input$selectedmz]][,2] - annot.res <- gsub('"','',annot.res) - annot.res - }) - output$mz <- renderUI({ - selectInput('selectedmz', 'm/z', availmz()) - }) - output$selectMF <- renderUI({ - selectInput('selectedMF', 'MF', availMF()) - }) - output$selectPIP <- renderUI({ - selectInput('selectedPIP', 'Putative Ionisation Product', availPIP()) - }) - output$accurate <- renderDataTable({ - if (is.null(loadData())){ - return(NULL) - } else { - annot.res <- loadData() - res <- annot.res[[input$mode]][["Accurate m/z"]] - rownames(res) <- NULL - res <- data.frame(res) - res[,2:3] <- apply(res[,2:3],2,as.numeric) - return(res) - } - }) - output$boxplot <- renderImage({ - files <- list.files(input$boxplots) - file <- grep(input$selectedmz,files) - if(length(file)>0){ - path <- paste(input$boxplots,files[file],sep="/") - } else { - path <- "" - } - list(src=path) - },deleteFile = FALSE) - output$binplot <- renderImage({ - files <- list.files(input$binplots) - file <- grep(input$selectedmz,files) - if(length(file)>0){ - path <- paste(input$binplots,files[file],sep="/") - } else { - path <- "" - } - list(src=path) - },deleteFile = FALSE) - output$correlation <- renderDataTable({ - if (is.null(loadData())){ - return(NULL) - } else { - annot.res <- loadData() - res <- annot.res[[input$mode]][["Correlation Analysis"]][[input$selectedmz]] - names(res)[c(1,4,5)] <- c("Bin","Relation To","Relation From") - if(nrow(res)>0){ - res[,4:5] <- apply(res[,4:5],2,function(x){x[which(x=="NA")] <- "";return(x)}) - res[,2] <- signif(res[,2],3) - } - return(res) - } - }) - output$MF <- renderDataTable({ - if (is.null(loadData())){ - return(NULL) - } else { - annot.res <- loadData() - res <- annot.res[[input$mode]][["Molecular Formulas"]][[input$selectedmz]] - names(res)[c(1,2,5,6)] <- c("Measured m/z", "Clean MF", "m/z", "PPM Error") - res[,5] <- round(as.numeric(res[,5]),5) - res[,6] <- round(as.numeric(res[,6]),3) - return(res) - } - }) - output$IsoDist <- renderTable({ - if (is.null(loadData())){ - return(NULL) - } else { - annot.res <- loadData() - res <- annot.res[[input$mode]][["Theoretical Isotope Distributions"]][[input$selectedmz]][[input$selectedMF]] - if(!is.null(res)){ - colnames(res)[3] <- "Relative Intensity" - } - return(res) - } - }) - output$isoplot <- renderPlot({ - if (is.null(loadData())){ - return(NULL) - } else { - annot.res <- loadData() - res <- annot.res[[input$mode]][["Theoretical Isotope Distributions"]][[input$selectedmz]][[input$selectedMF]] - if(!is.null(res)){ - plot(res[,1],res[,3],type="h",col="Blue",xlab="m/z",ylab="Relative Intensity") - } - } - }) - output$PIP <- renderDataTable({ - if (is.null(loadData())){ - return(NULL) - } else { - annot.res <- loadData() - res <- annot.res[[input$mode]][["Putative Ionisation Products"]][[input$selectedmz]] - names(res)[c(4,7,8)] <- c("Accurate Mass", "m/z","PPM Error") - res[,4] <- round(res[,4],5) - res[,7] <- round(res[,7],5) - res[,8] <- round(res[,8],3) - return(res) - } - }) - output$smile <- renderPlot({ - if (is.null(loadData())){ - return(NULL) - } else { - annot.res <- loadData() - res <- annot.res[[input$mode]][["Putative Ionisation Products"]][[input$selectedmz]] - if(nrow(res)>0){ - res[,2] <- gsub('"','',res[,2]) - smile <- res[which(res[,2]==input$selectedPIP),5] - par(mar=c(0,0,0,0)) - sm <- parse.smiles(smile)[[1]] - temp1 <- view.image.2d(sm,500,500) - plot(NA,NA,xlim=c(1,100),ylim=c(1,100),xaxt='n',yaxt='n',xlab='',ylab='') - rasterImage(temp1,1,1,100,100) # boundaries of raster: xmin, ymin, xmax, ymax. here i set them equal to plot boundaries - } - }},width=400,height=400) - } - ) -} \ No newline at end of file diff --git a/R/viewAnnotationLC.R b/R/viewAnnotationLC.R deleted file mode 100644 index c8e1aba..0000000 --- a/R/viewAnnotationLC.R +++ /dev/null @@ -1,131 +0,0 @@ -#' viewAnnotationLC -#' @export - -viewAnnotationLC <- function(){ - options(shiny.maxRequestSize = 20*1024^2) - options(digits=10) - shinyApp( - ui = fluidPage( - titlePanel("viewAnnotationLC"), - sidebarLayout( - sidebarPanel( - fileInput('file1', 'Upload Annotation:', - accept = c( - '.RData' - ) - ), - tags$hr(), - uiOutput("mz"), - tags$hr(), - textInput("boxplots","Box Plot Folder Path:") - ), - mainPanel( - tabsetPanel( - tabPanel("Peak Table", dataTableOutput('peakTab')), - tabPanel("Box Plots", imageOutput('boxplot')), - tabPanel('Correlation Analysis',dataTableOutput('corAnalysis')), - tabPanel("Putative Ionisation Products", - fluidRow(dataTableOutput('PIP')) - ), - tabPanel("PIP Structures", - fluidRow(uiOutput("selectPIP")), - plotOutput('smile') - ) - ) - ) - ) - ), - - server = function(input, output) { - loadData <- reactive({ - if(is.null(input$file1)) return(NULL) - load(input$file1$datapath) - featAnnot - }) - availmz <- reactive({ - if(is.null(loadData())) return(NULL) - featAnnot <- loadData() - names(featAnnot$featPIP) - }) - availPIP <- reactive({ - if(is.null(loadData())) return(NULL) - featAnnot <- loadData() - featAnnot <- featAnnot$featPIP[[input$selectedmz]][,2] - featAnnot <- gsub('"','',featAnnot) - featAnnot - }) - output$mz <- renderUI({ - selectInput('selectedmz', 'm/z', availmz()) - }) - output$selectPIP <- renderUI({ - selectInput('selectedPIP', 'Putative Ionisation Product', availPIP()) - }) - output$peakTab <- renderDataTable({ - if (is.null(loadData())){ - return(NULL) - } else { - featAnnot <- loadData() - res <- featAnnot[["peakTable"]] - rownames(res) <- NULL - res <- data.frame(res) - res[,c('rt','rtmin','rtmax')] <- round(res[,c('rt','rtmin','rtmax')]/60,3) - return(res) - } - }) - output$boxplot <- renderImage({ - files <- list.files(input$boxplots) - file <- grep(input$selectedmz,files) - if(length(file)>0){ - path <- paste(input$boxplots,files[file],sep="/") - } else { - path <- "" - } - list(src=path) - },deleteFile = FALSE) - output$corAnalysis <- renderDataTable({ - if (is.null(loadData())){ - return(NULL) - } else { - featAnnot <- loadData() - res <- featAnnot$corAnalysis[[input$selectedmz]] - colnames(res)[1] <- 'ID' - colnames(res)[6:7] <- c('Relation To','Relation From') - res$r <- round(res$r,3) - if(nrow(res)>0){ - res[,6:7] <- apply(res[,6:7],2,function(x){x[which(x=="NA")] <- "";return(x)}) - } - return(res) - } - }) - output$PIP <- renderDataTable({ - if (is.null(loadData())){ - return(NULL) - } else { - featAnnot <- loadData() - res <- featAnnot$featPIP[[input$selectedmz]] - names(res)[c(4,7,8)] <- c("Accurate Mass", "m/z","PPM Error") - res[,4] <- round(res[,4],5) - res[,7] <- round(res[,7],5) - res[,8] <- round(res[,8],3) - return(res) - } - }) - output$smile <- renderPlot({ - if (is.null(loadData())){ - return(NULL) - } else { - featAnnot <- loadData() - res <- featAnnot$featPIP[[input$selectedmz]] - if(nrow(res)>0){ - res[,2] <- gsub('"','',res[,2]) - smile <- res[which(res[,2]==input$selectedPIP),5] - par(mar=c(0,0,0,0)) - sm <- parse.smiles(smile)[[1]] - temp1 <- view.image.2d(sm,500,500) - plot(NA,NA,xlim=c(1,100),ylim=c(1,100),xaxt='n',yaxt='n',xlab='',ylab='') - rasterImage(temp1,1,1,100,100) # boundaries of raster: xmin, ymin, xmax, ymax. here i set them equal to plot boundaries - } - }},width=400,height=400) - } - ) -} \ No newline at end of file