Skip to content

Commit

Permalink
Merge branch 'feature/cleanup-and-refactor'
Browse files Browse the repository at this point in the history
  • Loading branch information
sneumann committed Mar 5, 2024
2 parents 09ab501 + 4b384c3 commit 2a9888f
Show file tree
Hide file tree
Showing 2 changed files with 214 additions and 0 deletions.
120 changes: 120 additions & 0 deletions tests/testthat/test_fileinput.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,123 @@ test_that("MSP reading works", {
# returnObj$precursorRt <- vector(mode = "numeric")

})

test_that("Project reading works", {
fileName <- system.file("extdata/showcase/Project_file_showcase_annotated.csv.gz", package = "MetFamily")
readDataList <- readClusterDataFromProjectFile(
file = fileName,
progress = FALSE)
#load("inst/extdata/testdata/readClusterDataFromProjectFile.Rdata")

expect_equal(length(readDataList), 59)
expect_equal(nrow(readDataList$dataFrameHeader), 3)
expect_equal(ncol(readDataList$dataFrameHeader), 14570)
expect_equal(length(readDataList$importParameterSet), 19)

#
# > str(dataList, max.level = 1)
# List of 59
# $ dataFrameHeader :'data.frame': 3 obs. of 14570 variables:
# $ dataFrameMS1Header :'data.frame': 3 obs. of 23 variables:
# $ dataFrameInfos :'data.frame': 2585 obs. of 23 variables:
# $ importParameterSet :List of 19
# $ numberOfPrecursors : int 2585
# $ numberOfDuplicatedPrecursors : int 0
# $ grouXXXps : chr [1:2] "TRI" "LVS"
# $ columnGroupLabels : chr [1:3, 1:2] "TRI" "TRI" "TRI" "LVS" ...
# ..- attr(*, "dimnames")=List of 2
# $ groupSampleDataFrame :'data.frame': 6 obs. of 4 variables:
# $ metaboliteProfileColumnNames : chr [1:23] "m/z" "RT" "Annotation" "Alignment ID" ...
# $ tagsSector : chr [1:23] "ID" "ID" "AnnotationColors={AS=#0000FF, SQT-glucosides=#FF0000}" "" ...
# $ fragmentMasses : num [1:14547] 69 71 71 71 73 ...
# $ fragmentFrequency : int [1:14547] 19 149 3 4 15 77 1 6 11 1 ...
# $ fragmentAbundance : num [1:14547] 0.1162 0.0899 0.131 0.1033 0.1987 ...
# $ minimumMass : num -1008
# $ maximumMass : num 1198
# $ precursorLabels : chr [1:2585] " 85.005 / 7.42" " 85.005 / 10.98" " 85.005 / 8.58" " 85.005 / 12.40" ...
# $ dataFrameMeasurements :'data.frame': 2585 obs. of 13 variables:
# $ meanAllMax : num 2441679
# $ logFoldChangeMax : num 10.5
# $ logAbsMax : num 6.7
# $ colorMatrixDataFrame : chr [1:2585, 1:13] "#8AFF00" "#E0FF00" "#9CFF00" "#EBFF00" ...
# ..- attr(*, "dimnames")=List of 2
# $ colorMapAbsoluteData :List of 6
# $ colorMapLogFoldChange :List of 6
# $ dataColumnsNameFunctionFromGroupName :function (group, sampleNamesToExclude)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 666 43 668 3 43 3 3786 3788
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ dataColumnsNameFunctionFromGroupIndex :function (groupIdx, sampleNamesToExclude)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 662 44 664 3 44 3 3782 3784
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ dataColumnsNameFunctionFromGroupNames :function (grouXXXps, sampleNamesToExclude)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 670 44 674 3 44 3 3790 3794
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ groupNameFunctionFromDataColumnName :function (dataColumnName, sampleNamesToExclude)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 676 42 682 3 42 3 3796 3802
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ lfcColumnNameFunctionFromString :function (columnName)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 464 38 469 3 38 3 3584 3589
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ dataMeanColumnNameFunctionFromString :function (columnName)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 470 43 473 3 43 3 3590 3593
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ dataColumnIndecesFunctionFromGroupIndex:function (groupIdx, sampleNamesToExclude)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 658 46 660 3 46 3 3778 3780
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ dataMeanColumnNameFunctionFromName :function (group)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 800 42 802 3 42 3 3920 3922
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ dataMeanColumnNameFunctionFromIndex :function (groupIdx)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 804 43 806 3 43 3 3924 3926
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ lfcColumnNameFunctionFromName :function (groupOne, groupTwo)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 808 36 810 3 36 3 3928 3930
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ lfcColumnNameFunctionFromIndex :function (groupIdxOne, groupIdxTwo)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 812 37 814 3 37 3 3932 3934
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ groupNameFromGroupIndex :function (groupIdx)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 816 30 818 3 30 3 3936 3938
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ groupIdxFromGroupName :function (group)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 820 28 822 3 28 3 3940 3942
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ featureMatrix :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
# $ featureIndeces :List of 2585
# $ featureCount : num [1:2585] 1 1 1 1 1 1 1 1 1 1 ...
# $ featureIndexMatrix : int [1:2585, 1:90] 15 15 15 15 15 15 15 15 15 15 ...
# ..- attr(*, "dimnames")=List of 2
# $ ms2_numberOfFragments : int [1:14547] 19 149 3 4 15 77 1 6 11 1 ...
# $ ms2_averageAbundance : num [1:14547] 0.1162 0.0899 0.131 0.1033 0.1987 ...
# $ ms2_masses : num [1:14547] 69 71 71 71 73 ...
# $ colorMapFragmentData :List of 6
# $ annotationColumnName : chr "Annotation"
# $ annotationColorsName : chr "AnnotationColors"
# $ annotationColumnIndex : int 3
# $ annotationValueIgnore : chr "Ignore"
# $ annotationColorIgnore : chr "red"
# $ annoArrayOfLists :List of 2585
# $ annoArrayIsArtifact : logi [1:2585] FALSE FALSE FALSE FALSE FALSE FALSE ...
# $ annoPresentAnnotationsList :List of 3
# $ annoPresentColorsList :List of 3
# $ orderColumnNames :function (groupSampleDataFrame, columnNames)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 685 23 691 3 23 3 3805 3811
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ excludedSamples :function (groupSampleDataFrame, grouXXXps = dataList$grouXXXps)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 695 22 700 3 22 3 3815 3820
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ includedSamples :function (groupSampleDataFrame, grouXXXps = dataList$grouXXXps)
# ..- attr(*, "srcref")= 'srcref' int [1:8] 702 22 707 3 22 3 3822 3827
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ includedGroups :function (groupSampleDataFrame, samples = dataList$groupSampleDataFrame[, "Sample"])
# ..- attr(*, "srcref")= 'srcref' int [1:8] 710 21 714 3 21 3 3830 3834
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
# $ excludedGroups :function (groupSampleDataFrame, samples = dataList$groupSampleDataFrame[, "Sample"])
# ..- attr(*, "srcref")= 'srcref' int [1:8] 716 21 718 3 21 3 3836 3838
# .. ..- attr(*, "srcfile")=Classes 'srcfilealias', 'srcfile' <environment: 0x555c0c5c55d0>
#
#
#
})


94 changes: 94 additions & 0 deletions vignettes/discoveringregulatedmetabolitefamilies.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
title: "Discovering regulated Metabolite Families"
author:
- name: Khabat Vahabi
affiliation: Leibniz Institute of Plant Biochemistry
- name: Steffen Neumann
affiliation: Second Author's Affiliation
email: [email protected]
package: MetFamily
output:
BiocStyle::html_document
abstract: |
Description of your vignette
vignette: |
%\VignetteIndexEntry{Vignette Title}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

# Getting started

To enable the _Bioconductor_ style in your R Markdown vignette you need to include the following in the `DESCRIPTION` file:

VignetteBuilder: knitr
Suggests: BiocStyle, knitr, rmarkdown


# Style macros

_BiocStyle_ introduces the following macros for referring to _R_ packages:

* `r Biocpkg("IRanges")`, for _Bioconductor_ software, annotation and experiment data packages,
* `r CRANpkg("data.table")`, for _R_ packages available on CRAN,
* `r Githubpkg("rstudio/rmarkdown")`, for _R_ packages available on GitHub,
* `r Rpackage("MyPkg")`, for _R_ packages that are _not_ available on _Bioconductor_, CRAN or GitHub.


# Figures

Assign captions to figures in the code chunk option `fig.cap` to automatically number them, and to be able to reference them, see Figure \@ref(fig:plot). The figure label is generated from the code chunk label by prefixing it with `fig:`.

```{r plot, fig.cap="Regular figure. The first sentence of the figure caption is automatically emphasized to serve as figure title.", echo=FALSE}
plot(cars)
```

Small and wide figures can be specified by `fig.small` and `fig.wide` code chunk options.

```{r small, fig.cap="Small figure. A plot produced by a code chunk with option `fig.small = TRUE`.", fig.small=TRUE, echo=FALSE}
plot(cars)
```
```{r wide, fig.cap="Wide figure. A plot produced by a code chunk with option `fig.wide = TRUE`.", fig.wide=TRUE, echo=FALSE}
plot(cars)
```


# Equations

To number and reference equations, put them in equation environments and assign labels to them, see Equation \@ref(eq:binom).

\begin{equation}
f\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k}
(\#eq:binom)
\end{equation}


# Tables

Like figures, tables with captions will also be numbered and can be referenced, see Table \@ref(tab:table).

Fruit | Price
------- | -----
bananas | 1.2
apples | 1.0
oranges | 2.5

: (\#tab:table) A simple table. With caption.


# Cross-references

Apart from referencing figures (Section \@ref(figures)), tables (Section \@ref(tables)), and equations (Section \@ref(equations)), you can also use the same syntax to refer to sections by their default labels generated by pandoc.


# Side notes

Footnotes are displayed as side notes on the right margin^[this is a side note entered as a footnote], which has the advantage that they appear close to the place where they are defined.


# Session info {.unnumbered}

```{r sessionInfo, echo=FALSE}
sessionInfo()
```

0 comments on commit 2a9888f

Please sign in to comment.