Skip to content

Commit e70c746

Browse files
authored
Merge pull request #23 from sterrettJD/bioconductor
Setup bioconductor compatibility
2 parents 9e0e8fd + 3dbb0cb commit e70c746

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3013
-700
lines changed

.Rbuildignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
^.*\.Rproj$
1+
^benchmarking/
2+
^.*\.pdf$
3+
^.*\.tar\.gz$
4+
^\.DS_Store$
5+
^\.git$
6+
^\.github$
7+
^\.gitignore$
8+
^\.Rhistory$
29
^\.Rproj\.user$
10+
^HoMiStats\.Rproj$
11+
^notes/

DESCRIPTION

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
Package: HoMiStats
22
Type: Package
33
Title: Stats for host-microbiome dual transcriptomics
4-
Version: 0.1.0
5-
Author: John Sterrett
6-
Maintainer: John Sterrett <john.sterrett@colorado.edu>
7-
Description: Stats for host-microbiome dual transcriptomics
8-
Contains tools for metatranscriptome differential expression and
9-
for creating co-occurrence networks between host and microbial transcripts
10-
Imports: gamlss, gamlss.dist, broom, broom.mixed, ggplot2, tidyverse, lme4, ZIBR, dplyr, lmerTest, Matrix, parallel, foreach, doParallel, doSNOW, plyr, Rfast, AnnotationDbi, org.Hs.eg.db, DESeq2
11-
License: MIT
4+
Version: 0.99.0
5+
Authors@R: person("John", "Sterrett",
6+
email = "sterrettjd@protonmail.com",
7+
role = c("aut", "cre"),
8+
comment = c(ORCID = "0000-0002-0931-7181"))
9+
Description: Statistical tooling for host-microbiome dual transcriptomics.
10+
HoMiStats contains tools for metatranscriptome differential expression and
11+
for creating co-occurrence networks between host and microbial transcripts.
12+
Additionally, there are tools for transforming data and
13+
performing targeted (knowledge-guided) analyses to look for
14+
biologically-plausible associations in gene expression between
15+
hosts and microbes.
16+
Imports: gamlss, gamlss.dist, broom, broom.mixed, ggplot2, tidyverse, lme4, ZIBR, dplyr, lmerTest, Matrix, parallel, foreach, doParallel, doSNOW, plyr, Rfast, AnnotationDbi, org.Hs.eg.db, DESeq2, stats, utils, stringr
17+
License: MIT + file LICENSE
1218
Encoding: UTF-8
13-
LazyData: true
1419
Suggests:
1520
knitr,
1621
rmarkdown,
1722
testthat (>= 3.0.0)
1823
VignetteBuilder: knitr
1924
Config/testthat/edition: 3
25+
URL: https://github.com/sterrettJD/HoMiStats
26+
BugReports: https://github.com/sterrettJD/HoMiStats/issues
27+
biocViews: GeneExpression, Regression, DifferentialExpression, Transcriptomics, Metagenomics, Microbiome, KEGG
28+
RoxygenNote: 7.3.2

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright <2025> <John Sterrett>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

NAMESPACE

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
exportPattern("^[[:alpha:]]+")
2-
import(gamlss)
3-
import(gamlss.dist)
42
import(ZIBR)
5-
import(lme4)
6-
import(lmerTest)
73
import(foreach)
84
import(DESeq2)
5+
import(ggplot2)
6+
import(tidyverse)
7+
import(Matrix)
8+
importFrom(gamlss, gamlss)
9+
importFrom(gamlss, gamlss.control)
10+
importFrom(gamlss.dist, BEZI)
11+
importFrom(lmerTest, lmer)
12+
importFrom(lme4, findbars)
913
importFrom(parallel, makeCluster)
1014
importFrom(parallel, stopCluster)
1115
importFrom(doParallel, registerDoParallel)
1216
importFrom(doSNOW, registerDoSNOW)
1317
importFrom(broom.mixed, tidy)
1418
importFrom(broom, tidy)
15-
importFrom("stats", "as.formula", "p.adjust")
16-
importFrom("utils", "setTxtProgressBar", "txtProgressBar")
19+
importFrom("stats", "as.formula", "p.adjust","lm", "var")
20+
importFrom("utils", "setTxtProgressBar", "txtProgressBar", "download.file")
1721
importFrom(plyr, mapvalues)
1822
importFrom(Rfast, comb_n)
1923
importFrom(AnnotationDbi, select)
2024
importFrom(org.Hs.eg.db, org.Hs.eg.db)
21-
25+
importFrom(stringr, str_split)

R/GMMs.R

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
#' Download GMMs file
2-
#' @description Pulls the Raes lab gut metabolic modules file (v1.0.7). Will not overwrite an existing file.
2+
#' @description Pulls the Raes lab gut metabolic modules file (v1.0.7).
3+
#' This will not overwrite an existing file.
34
#' @param filepath The filepath where the GMMs file should be downloaded
5+
#' @param version The version of GMMs to be used.
6+
#' As of April '24, the newest version is v1.07.
7+
#' This is used in pulling the data from the Raes lab GMMs github,
8+
#' so old versions that are not on the master branch
9+
#' may cause the filepath to not work.
10+
#' @param quietly A boolean denoting if the GMMs file
11+
#' should be downloaded quietly
412
#' @return Nothing
13+
#'
14+
#' @examples
15+
#' pull_GMMs_file("loc_to_download.txt")
16+
#'
17+
#' # cleanup
18+
#' file.remove("loc_to_download.txt")
519
#' @export
620
#'
721
pull_GMMs_file <- function(filepath, version="v1.07", quietly=TRUE){
822
if(!file.exists(filepath)){
9-
gmm.url <- paste0("https://raw.githubusercontent.com/raeslab/GMMs/master/GMMs.",
10-
version, ".txt")
23+
gmm.url <- paste0("https://raw.githubusercontent.com/",
24+
"raeslab/GMMs/master/GMMs.",
25+
version, ".txt")
1126
download.file(gmm.url,
12-
filepath,
13-
quiet=quietly)
27+
filepath,
28+
quiet=quietly)
1429
} else {
1530
warning("File already exists.")
1631
}
@@ -20,12 +35,19 @@ pull_GMMs_file <- function(filepath, version="v1.07", quietly=TRUE){
2035
#' Adds KEGG line to the GMM matrix
2136
#' @description Parser for each line of the GMM file
2237
#' @param GMM.matrix The matrix with GMM data
23-
#' @param line A string containing the line to be parsed and added to the GMM matrix
24-
#' @param mod.name A string containing the name of the module for which current line is being parsed
25-
#' @param mod.number A string containing the ID of the module for which current line is being parsed
38+
#' @param line A string containing the line
39+
#' to be parsed and added to the GMM matrix
40+
#' @param mod.name A string containing the name of the module
41+
#' for which current line is being parsed
42+
#' @param mod.number A string containing the ID of the module
43+
#' for which current line is being parsed
2644
#' @return The updated matrix of GMMs, with the new line parsed and added
2745
#'
28-
add_K_line_to_matrix <- function(GMM.matrix, line, mod.name, mod.number){
46+
#' @importFrom stringr str_split
47+
#'
48+
#' @keywords internal
49+
#'
50+
.add_K_line_to_matrix <- function(GMM.matrix, line, mod.name, mod.number){
2951
# Splits line on either a comma or tab
3052
split.line <- stringr::str_split(line, "[,\t]")[[1]]
3153
new.GMM.matrix <- GMM.matrix
@@ -38,24 +60,37 @@ add_K_line_to_matrix <- function(GMM.matrix, line, mod.name, mod.number){
3860
}
3961

4062
#' Gets the GMM matrix in a tabular format
41-
#' @description Download the GMM data (if needed) and parses this file to return a table with the GMMs and corresponding KOs
42-
#' @param filepath The filepath at which the GMMs file should be downloaded or found.
43-
#' @param version The version of GMMs to be used. As of April '24, the newest version is v1.07. This is used in pulling the data from the Raes lab GMMs github, so old versions that are not on the master branch may cause the filepath to not work.
44-
#' @param quietly A boolean denoting if the GMMs file should be downloaded quietly
45-
#' @param cleanup A boolean denoting if the filepath should be removed at the end of this function.
63+
#' @description Download the GMM data (if needed) and
64+
#' parses this file to return a table with the GMMs and corresponding KOs
65+
#' @param filepath The filepath at which
66+
#' the GMMs file should be downloaded or found.
67+
#' @param version The version of GMMs to be used.
68+
#' As of April '24, the newest version is v1.07.
69+
#' This is used in pulling the data from the Raes lab GMMs github,
70+
#' so old versions that are not on the master branch
71+
#' may cause the filepath to not work.
72+
#' @param quietly_download A boolean denoting if the GMMs file
73+
#' should be downloaded quietly
74+
#' @param cleanup A boolean denoting if the filepath
75+
#' should be removed at the end of this function.
4676
#' @return A tabular version of the GMMs as a dataframe
77+
#'
78+
#' @examples
79+
#' GMM.df <- get_GMM_matrix()
80+
#'
4781
#' @export
4882
#'
4983
get_GMM_matrix <- function(filepath="GMMs.txt", version="v1.07",
50-
quietly_download=TRUE, cleanup=TRUE){
84+
quietly_download=TRUE, cleanup=TRUE){
5185
if(!file.exists(filepath)){
52-
pull_GMMs_file(filepath=filepath, version=version, quietly=quietly_download)
86+
pull_GMMs_file(filepath=filepath, version=version,
87+
quietly=quietly_download)
5388
}
5489

5590
GMM.fileconts <- readLines(filepath)
5691

57-
GMM.matrix <- matrix(data=c("KEGG","Module","Module ID"), nrow=1, ncol=3)
58-
for(i in 1:length(GMM.fileconts)){
92+
GMM.matrix <- matrix(data=c("KEGG", "Module", "Module ID"), nrow=1, ncol=3)
93+
for(i in seq_len(length(GMM.fileconts))){
5994
line <- GMM.fileconts[i]
6095
# if new module, get its name and number
6196
if(grepl("^MF\\d{4}", line)){
@@ -65,7 +100,8 @@ get_GMM_matrix <- function(filepath="GMMs.txt", version="v1.07",
65100
}
66101
# If KO line, add that info to the matrix
67102
else if(grepl("^K\\d{5}", line)){
68-
GMM.matrix <- add_K_line_to_matrix(GMM.matrix, line, mod.name, mod.number)
103+
GMM.matrix <- .add_K_line_to_matrix(GMM.matrix, line,
104+
mod.name, mod.number)
69105
}
70106
}
71107

@@ -78,7 +114,7 @@ get_GMM_matrix <- function(filepath="GMMs.txt", version="v1.07",
78114
GMM.matrix <- GMM.matrix[GMM.matrix$KEGG!="",]
79115

80116
if(cleanup){
81-
message(paste("Deleting", filepath))
117+
message("Deleting ", filepath)
82118
file.remove(filepath)
83119
}
84120
return(GMM.matrix)

0 commit comments

Comments
 (0)