Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Feature/cleanup and refactor #76

Merged
merged 16 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: MetFamily
Type: Package
Title: MetFamily: Discovering Regulated Metabolite Families in Untargeted Metabolomics Studies
Version: 0.99.2
Version: 0.99.3
Date: 2024-03-02
Author: c( person("Hendrik", "Treutler, role = c("aut"), email = "hendrik.treutler@ipb-halle.de"),
person("Khabat", "Vahabi, role = c("aut"), email = "khabat.vahabi@ipb-halle.de"),
Expand All @@ -27,31 +27,40 @@ Depends:
searchable,
tools,
stringr,
xcms,
mzR,
matrixStats,
plotrix,
slam,
plotly,
egg
plotly
Imports:
egg,
graphics,
grDevices,
methods,
stats,
utils
Remotes: decisionpatterns/searchable
Suggests:
knitr,
testthat
VignetteBuilder: knitr
Maintainer: Hendrik Treutler<hendrik.treutler@ipb-halle.de>
Description: We present a novel approach for the untargeted discovery of metabolite families offering a bird's eye view of metabolic regulation in comparative metabolomics. We implemented the presented methodology in the easy-to-use web application MetFamily to enable the analysis of comprehensive metabolomics studies for all researchers worldwide.
License: GPL (>= 2)
Description: We present a novel approach for the untargeted discovery
of metabolite families offering a bird's eye view of metabolic regulation
in comparative metabolomics. We implemented the presented methodology
in the easy-to-use web application MetFamily to enable the analysis
of comprehensive metabolomics studies for all researchers worldwide.
License: GPL (>= 2) + file LICENSE
biocViews: Software, Visualization
Collate:
'Annotation.R'
'Classifiers.R'
'runMetFamily.R'
'R_packages.R'
'FragmentMatrixFunctions.R'
'DataProcessing.R'
'Analysis.R'
'TreeAlgorithms.R'
'Plots.R'
'R_packages.R'
RoxygenNote: 7.2.3
Encoding: UTF-8
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#FROM sneumann/metfamily-base:latest
#FROM sneumann/metfamily-base:4.3.2
FROM sneumann/metfamily-base:4.3.2
#FROM sneumann/metfamily-base:4.0.5
FROM sneumann/metfamily-base:3.6.3
#FROM sneumann/metfamily-base:3.6.3

MAINTAINER Steffen Neumann <sneumann@ipb-halle.de>

Expand Down
27 changes: 26 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
#export(startMetFamily)
# Generated by roxyXXXgen2: do not edit by hand

## Hardcoded:
exportPattern("^[^\\.]")
import(egg)
importFrom("grDevices", "as.raster", "rainbow", "rgb")
importFrom("methods", "as")
importFrom("graphics", "axis", "mtext", "par", "plot.new",
"plot.window", "points", "rasterImage", "rect", "segments",
"title")
importFrom("methods", "as", "is")
importFrom("stats", "as.dendrogram", "cor", "dendrapply", "dist",
"hclust", "is.leaf", "median", "na.omit", "predict", "sd")
importFrom("utils", "flush.console", "read.table")


## From roxygen:
export(calcPlotDendrogram_plotly)
export(calcPlotHeatmapLegend)
export(castListEntries)
export(data.numericmatrix)
export(metaboliteFamilyVersusClass)
export(mzClustGeneric)
export(processMS1data)
export(readClusterDataFromProjectFile)
export(readProjectData)
export(runMetFamily)
importFrom(grDevices,colorRampPalette)
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGES IN VERSION 0.99.2
-------------------------

BUG FIXES

o Now producing correct PCA on R-4.0.0+ by using a custom data.matrix() function with old R-3.6.3 behaviour

CHANGES IN VERSION 0.99.2
-------------------------

NEW FEATURES

o More and better colors available for plotting (thanks @khabatv)
Expand Down
24 changes: 12 additions & 12 deletions R/Analysis.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#########################################################################################
## constants
filterData <- function(dataList, groups, sampleSet, filterBySamples, filter_average, filter_lfc, filterList_ms2_masses, filter_ms2_ppm, filter_ms1_masses, filter_ms1_ppm, includeIgnoredPrecursors, progress = FALSE){
filterData <- function(dataList, grouXXXps, sampleSet, filterBySamples, filter_average, filter_lfc, filterList_ms2_masses, filter_ms2_ppm, filter_ms1_masses, filter_ms1_ppm, includeIgnoredPrecursors, progress = FALSE){
##########################################
## filter
filter <- rep(x = TRUE, times = dataList$numberOfPrecursors)
Expand All @@ -10,9 +10,9 @@ filterData <- function(dataList, groups, sampleSet, filterBySamples, filter_aver
if(!is.null(filter_average)){
#print("this is entering the line 11")
#if(filterBySamples){
# filter <- filter & apply(X = as.data.frame(dataList$dataFrameMeasurements[, sapply(X = as.vector(groups), FUN = dataList$dataMeanColumnNameFunctionFromName)]), MARGIN = 1, FUN = mean) >= filter_average
# filter <- filter & apply(X = as.data.frame(dataList$dataFrameMeasurements[, sapply(X = as.vector(grouXXXps), FUN = dataList$dataMeanColumnNameFunctionFromName)]), MARGIN = 1, FUN = mean) >= filter_average
#} else {
filter <- filter & apply(X = as.data.frame(dataList$dataFrameMeasurements[, sapply(X = as.vector(groups), FUN = dataList$dataMeanColumnNameFunctionFromName)]), MARGIN = 1, FUN = mean) >= filter_average
filter <- filter & apply(X = as.data.frame(dataList$dataFrameMeasurements[, sapply(X = as.vector(grouXXXps), FUN = dataList$dataMeanColumnNameFunctionFromName)]), MARGIN = 1, FUN = mean) >= filter_average
#print(filter)
#print(names(filter)[unname(filter)])
#}
Expand All @@ -21,11 +21,11 @@ filterData <- function(dataList, groups, sampleSet, filterBySamples, filter_aver
## filter_lfc
if(!is.null(filter_lfc)){
if(filter_lfc != 0){
if(length(groups) != 2){ stop("The number of groups for LFC is not equal to two!") }
if(length(grouXXXps) != 2){ stop("The number of grouXXXps for LFC is not equal to two!") }
if(filter_lfc > 0)
filter <- filter & dataList$dataFrameMeasurements[, dataList$lfcColumnNameFunctionFromName(groups[[1]], groups[[2]])] >= filter_lfc
filter <- filter & dataList$dataFrameMeasurements[, dataList$lfcColumnNameFunctionFromName(grouXXXps[[1]], grouXXXps[[2]])] >= filter_lfc
else
filter <- filter & dataList$dataFrameMeasurements[, dataList$lfcColumnNameFunctionFromName(groups[[1]], groups[[2]])] <= filter_lfc
filter <- filter & dataList$dataFrameMeasurements[, dataList$lfcColumnNameFunctionFromName(grouXXXps[[1]], grouXXXps[[2]])] <= filter_lfc
}
}

Expand Down Expand Up @@ -80,16 +80,16 @@ filterData <- function(dataList, groups, sampleSet, filterBySamples, filter_aver
resultObj$filter <- filter
resultObj$numberOfPrecursors <- dataList$numberOfPrecursors
resultObj$numberOfPrecursorsFiltered <- length(filter)
if(is.null(groups)){
resultObj$groups <- list()
if(is.null(grouXXXps)){
resultObj$grouXXXps <- list()
resultObj$sampleSet <- list()
resultObj$filterBySamples <- NA
} else {
resultObj$groups <- groups
resultObj$grouXXXps <- grouXXXps
resultObj$sampleSet <- sampleSet
resultObj$filterBySamples <- filterBySamples
}
#resultObj$groups <- ifelse(test = is.null(groups), yes = NA, no = groups)
#resultObj$grouXXXps <- ifelse(test = is.null(grouXXXps), yes = NA, no = grouXXXps)
resultObj$filter_average <- ifelse(test = is.null(filter_average), yes = 0, no = filter_average)
resultObj$filter_lfc <- ifelse(test = is.null(filter_lfc), yes = 0, no = filter_lfc)
if(is.null(filterList_ms2_masses)){
Expand Down Expand Up @@ -974,7 +974,7 @@ performPca <- function(dataList, dataFrame2, ms1AnalysisMethod){
#.. ..$ : chr [1:5] "Dim.1" "Dim.2" "Dim.3" "Dim.4" ...
#$ variance: num [1:18] 35.96 21.67 11.66 8.15 4.56 ...
#
## artificial data two groups
## artificial data two grouXXXps
#$ scores : num [1:2, 1] 0 0
#..- attr(*, "dimnames")=List of 2
#.. ..$ : chr [1:2] "A_1" "B_2"
Expand Down Expand Up @@ -1054,7 +1054,7 @@ calculatePCA <- function(dataList, filterObj, ms1AnalysisMethod, scaling, logTra
if(filterObj$filterBySamples){
dataFrame <- dataList$dataFrameMeasurements[filterObj$filter, filterObj$sampleSet]
} else {
dataFrame <- dataList$dataFrameMeasurements[filterObj$filter, dataList$dataColumnsNameFunctionFromGroupNames(groups = filterObj$groups, sampleNamesToExclude = dataList$excludedSamples(dataList$groupSampleDataFrame))]
dataFrame <- dataList$dataFrameMeasurements[filterObj$filter, dataList$dataColumnsNameFunctionFromGroupNames(grouXXXps = filterObj$grouXXXps, sampleNamesToExclude = dataList$excludedSamples(dataList$groupSampleDataFrame))]
}
dataFrame <- t(dataFrame)

Expand Down
18 changes: 18 additions & 0 deletions R/Annotation.R
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,24 @@ evaluatePutativeMetaboliteFamiliesOfPrecursorSet_old <- function(dataList, precu
return(printPutativeMetaboliteFamilies)
}



#' Title
#'
#' @param dataList
#' @param precursorSet
#' @param classToSpectra_class
#' @param properties_class
#' @param classifierClass
#' @param mappingSpectraToClassDf
#' @param addClassifierConsensusSpectrum
#'
#' @return
#' @export
#' @importFrom grDevices colorRampPalette
#'
#'
#' @examples
metaboliteFamilyVersusClass <- function(dataList, precursorSet, classToSpectra_class, properties_class, classifierClass, mappingSpectraToClassDf, addClassifierConsensusSpectrum){
returnObj <- getSpectrumStatistics(dataList = dataList, precursorSet = precursorSet)
masses_spec <- returnObj$fragmentMasses
Expand Down
Loading
Loading