Skip to content

Commit

Permalink
Merge pull request #77 from khabatv/master
Browse files Browse the repository at this point in the history
changing prettynum, digits = 0 to 1
  • Loading branch information
sneumann authored Mar 10, 2024
2 parents 87fd457 + 6769831 commit 625e593
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion R/DataProcessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,7 @@ getTableFromPrecursorSet <- function(dataList, precursorSet){
featureMatrix <- data.frame(as.matrix(dataList$featureMatrix[precursorSet, featureIndeces, drop = FALSE]))
rownames(featureMatrix) <- dataList$precursorLabels[precursorSet]
colnames(featureMatrix) <- colnames(dataList$featureMatrix)[featureIndeces]
featureMatrix <- format(x = featureMatrix, digits = 0, nsmall = 4)
featureMatrix <- format(x = featureMatrix, digits = 1, nsmall = 4)
if(length(featureIndeces) > 0){
featureMatrix[featureMatrix=="0.0000"] <- "-"
featureMatrix[featureMatrix=="1.0000"] <- "1"
Expand Down
2 changes: 1 addition & 1 deletion R/FragmentMatrixFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,7 @@ convertToProjectFile2 <- function(filePeakMatrix,
if(isGC){
## round GC mzs to integer
for(spectrumIdx in seq_len(length(spectraList))){
spectraList[[spectrumIdx]]$ms2Peaks_mz <- round(x = spectraList[[spectrumIdx]]$ms2Peaks_mz, digits = 0)
spectraList[[spectrumIdx]]$ms2Peaks_mz <- round(x = spectraList[[spectrumIdx]]$ms2Peaks_mz, digits = 1)
}
}

Expand Down
12 changes: 6 additions & 6 deletions R/Plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -2154,7 +2154,7 @@ calcPlotMS2 <- function(dataList, fragmentsX = NULL, fragmentsY = NULL, fragment
if(length(dataX) > 0){
## axis with the individual fragment m/z's (ticks, labels)
axis(side = 1, at = dataX, labels = FALSE, las = 2)
axis(side = 1, at = tickPositions, labels = format(x = dataX, digits = 0, nsmall = 4), las = 2, tick = FALSE)
axis(side = 1, at = tickPositions, labels = format(x = dataX, digits = 1, nsmall = 4), las = 2, tick = FALSE)

## sticks
points(x = dataX, y = dataY, col = nodeColors, type = "h", lwd=4)
Expand Down Expand Up @@ -4961,7 +4961,7 @@ plotFragments <- function(masses, numberOfFragments, colors = NULL, numberOfPrec
#axis(side = 1, at = dataList$ms2_masses, labels = dataList$ms2_masses, las = 2, tick = TRUE, col = colors)
#for(i in 1:length(dataList$ms2_masses))
for(i in dataOrder)
axis(side = 1, at = masses[[i]], labels = format(x = masses[[i]], digits = 0, nsmall = 4), las = 2, tick = TRUE, col.axis = colors[[i]])
axis(side = 1, at = masses[[i]], labels = format(x = masses[[i]], digits = 1, nsmall = 4), las = 2, tick = TRUE, col.axis = colors[[i]])

points(x = masses[dataOrder], y = numberOfFragments[dataOrder], col = colors[dataOrder], type = "h", lwd=4)
#points(x = masses[dataOrder], y = numberOfFragments[dataOrder], col = colors[dataOrder], pch=19, cex=1.)
Expand Down Expand Up @@ -5040,7 +5040,7 @@ plotFragments2 <- function(masses, numberOfFragments, numberOfPrecursors, xInter
#axis(side = 1, at = masses, labels = masses, las = 2, tick = TRUE, col = colors)
#for(i in 1:length(masses))
for(i in dataOrder)
axis(side = 1, at = masses[[i]], labels = format(x = masses[[i]], digits = 0, nsmall = 4), las = 2, tick = TRUE, col.axis = colors[[i]])
axis(side = 1, at = masses[[i]], labels = format(x = masses[[i]], digits = 1, nsmall = 4), las = 2, tick = TRUE, col.axis = colors[[i]])

points(x = masses[dataOrder], y = numberOfFragments[dataOrder], col = colors[dataOrder], type = "h", lwd=4)
#points(x = masses[dataOrder], y = numberOfFragments[dataOrder], col = colors[dataOrder], pch=19, cex=1.)
Expand Down Expand Up @@ -5161,12 +5161,12 @@ calcPlotSpectrumVsClass_big <- function(masses_spec, intensity_spec, colors_spec

## axis with the individual fragment m/z's (ticks, labels)
axis(side = 1, at = masses_spec, labels = FALSE, las = 2)
axis(side = 1, at = masses_spec[-these], labels = format(x = masses_spec[-these], digits = 0, nsmall = 4), las = 2, tick = FALSE, col.axis = "grey")
axis(side = 1, at = masses_spec[-these], labels = format(x = masses_spec[-these], digits = 1, nsmall = 4), las = 2, tick = FALSE, col.axis = "grey")
if(length(these) == 1){
if(these != length(masses_spec)+1)
axis(side = 1, at = masses_spec[ these], labels = format(x = masses_spec[ these], digits = 0, nsmall = 4), las = 2, tick = FALSE, col.axis = "black")
axis(side = 1, at = masses_spec[ these], labels = format(x = masses_spec[ these], digits = 1, nsmall = 4), las = 2, tick = FALSE, col.axis = "black")
} else {
axis(side = 1, at = masses_spec[ these], labels = format(x = masses_spec[ these], digits = 0, nsmall = 4), las = 2, tick = FALSE, col.axis = "black")
axis(side = 1, at = masses_spec[ these], labels = format(x = masses_spec[ these], digits = 1, nsmall = 4), las = 2, tick = FALSE, col.axis = "black")
}

## sticks
Expand Down
6 changes: 3 additions & 3 deletions inst/MetFamily/app_files/server_guiMs2plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ obsMS2hover <- observeEvent(input$plotMS2_hover, {
print(paste("update output$information"))
paste(
"Fragment with m/z = ", ms2PlotValues$fragmentListClicked$fragmentMasses[[minimumIndex]],
" and (average) abundance = ", format(x = ms2PlotValues$fragmentListClicked$fragmentAbundances[[minimumIndex]], digits = 0, nsmall = 4),
" and (average) abundance = ", format(x = ms2PlotValues$fragmentListClicked$fragmentAbundances[[minimumIndex]], digits = 1, nsmall = 4),
" is present in ", numberOfPrecursors, " MS/MS spectra",
"\nand has a cluster-discriminating power of ", format(x = ms2PlotValues$fragmentListClicked$fragmentDiscriminativity[[minimumIndex]]*100, digits = 3, nsmall = 2), "%.",
sep = ""
Expand Down Expand Up @@ -164,7 +164,7 @@ output$plotMS2_hover_info <- renderUI({
# print(paste("update output$information"))
# paste(
# "Fragment with m/z = ", ms2PlotValues$fragmentListClicked$fragmentMasses[[minimumIndex]],
# " and (average) abundance = ", format(x = ms2PlotValues$fragmentListClicked$fragmentAbundances[[minimumIndex]], digits = 0, nsmall = 4),
# " and (average) abundance = ", format(x = ms2PlotValues$fragmentListClicked$fragmentAbundances[[minimumIndex]], digits = 1, nsmall = 4),
# " is present in ", numberOfPrecursors, " MS/MS spectra",
# "\nand has a cluster-discriminating power of ", format(x = ms2PlotValues$fragmentListClicked$fragmentDiscriminativity[[minimumIndex]]*100, digits = 3, nsmall = 2), "%.",
# sep = ""
Expand All @@ -173,7 +173,7 @@ output$plotMS2_hover_info <- renderUI({

fragmentMz <- ms2PlotValues$fragmentListClicked$fragmentMasses[[minimumIndex]]
fragmentMzS <- format(x = fragmentMz, nsmall = 4)
intensityS <- format(x = ms2PlotValues$fragmentListClicked$fragmentAbundances[[minimumIndex]], digits = 0, nsmall = 4)
intensityS <- format(x = ms2PlotValues$fragmentListClicked$fragmentAbundances[[minimumIndex]], digits = 1, nsmall = 4)
cdpS <- format(x = ms2PlotValues$fragmentListClicked$fragmentDiscriminativity[[minimumIndex]]*100, digits = 3, nsmall = 2)

info <- paste(
Expand Down
4 changes: 2 additions & 2 deletions inst/MetFamily/app_files/server_guiTabHca.R
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ obsHeatmaphover <- observeEvent(input$plotHeatmap_hover, {

#################################################
## info
treeLeafIndex2 <- as.numeric(format(x = hoverX, digits = 0))
treeLeafIndex2 <- as.numeric(format(x = hoverX, digits = 1))
treeLeafIndex <- clusterDataList$cluster$order[[treeLeafIndex2]]
precursorIndex <- filterHca$filter[[treeLeafIndex]]

Expand Down Expand Up @@ -698,7 +698,7 @@ output$plotHeatmap_hover_info <- renderUI({
return(NULL)

#################################################
treeLeafIndex2 <- as.numeric(format(x = hoverX, digits = 0))
treeLeafIndex2 <- as.numeric(format(x = hoverX, digits = 1))
treeLeafIndex <- clusterDataList$cluster$order[[treeLeafIndex2]]
precursorIndex <- filterHca$filter[[treeLeafIndex]]

Expand Down

0 comments on commit 625e593

Please sign in to comment.