-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c97210
commit 6c0eff1
Showing
11 changed files
with
228 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
.Ruserdata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Package: microsig | ||
Type: Package | ||
Title: Calculates Microbe Signature Score | ||
Version: 0.0.0.9000 | ||
Authors@R: | ||
c(person(given = "Caroline", | ||
family = "Wheeler", | ||
role = c("aut"), | ||
comment = c(ORCID = "0000-0002-3374-4909")), | ||
person(given = "Rebecca", | ||
family = "Hoyd", | ||
role = c("aut"), | ||
comment = c(ORCID = "0000-0003-1210-4491")), | ||
person(given = "Daniel", | ||
family = "Spakowicz", | ||
role = c("aut", "cre"), | ||
email = "daniel.spakowicz@osumc.edu", | ||
comment = c(ORCID = "0000-0003-2314-6435")) | ||
Maintainer: Daniel Spakowicz <daniel.spakowicz@osumc.edu> | ||
Description: This package contains functions to calculate microbe signatures, particularly from bugsigdb inputs. | ||
License: MIT | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.2.3 | ||
Imports: | ||
dplyr, | ||
tidyr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(calcMicroSigScore) | ||
export(getSigList) | ||
export(microbeEntries) | ||
import(dplyr) | ||
import(tidyr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#' Function to calculate microbe signature scores given a set of up and down | ||
#' regulated microbes and the relative abundances of microbe per sample | ||
#' | ||
#' @param taxa a data frame where columns are microbes and rows are samples, first | ||
#' column named 'sample' | ||
#' @param sig.up a character vector listing microbes in given signature that are | ||
#' up-regulated, empty if none | ||
#' @param sig.down a character vector listing microbes in given signature that are | ||
#' down-regulated, empty if none | ||
#' | ||
#' @return a data frame with samples and corresponding microbe signature scores | ||
#' | ||
#' @import dplyr | ||
#' @import tidyr | ||
#' | ||
#' @export | ||
calcMicroSigScore <- function(taxa, sig.up, sig.down){ | ||
df <- taxa %>% | ||
tidyr::gather(microbe, exo.ra, -sample) %>% | ||
dplyr::group_by(sample) %>% | ||
dplyr::mutate(z_score = scale(exo.ra)) | ||
|
||
upMics <- df %>% | ||
dplyr::filter(microbe %in% sig.up) | ||
|
||
upTotal <- length(unique(upMics$microbe)) | ||
|
||
upMics <- upMics %>% | ||
dplyr::group_by(sample) %>% | ||
dplyr::summarize(tempUp = sum(exo.ra)) | ||
|
||
downMics <- df %>% | ||
dplyr::filter(microbe %in% sig.down) | ||
|
||
downTotal <- length(unique(downMics$microbe)) | ||
|
||
downMics <- downMics %>% | ||
dplyr::group_by(sample) %>% | ||
dplyr::summarize(tempDown = sum(exo.ra)) | ||
|
||
if(upTotal == 0 && downTotal == 0){ | ||
df <- data.frame(matrix(ncol = 0, nrow = 0)) | ||
}else if(upTotal == 0){ | ||
df <- downMics %>% | ||
dplyr::mutate(score = tempDown*(1/downTotal)) %>% | ||
dplyr::select(sample,score) | ||
}else if(downTotal == 0){ | ||
df <- upMics %>% | ||
dplyr::mutate(score = tempUp*(1/upTotal)) %>% | ||
dplyr::select(sample, score) | ||
}else{ | ||
df <- merge(upMics, downMics, by = "sample") %>% | ||
dplyr::mutate(score = (tempUp - tempDown)*(1/(upTotal + downTotal))) %>% | ||
dplyr::select(sample, score) | ||
} | ||
|
||
return(df) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#' Given a single cell value from bigsigDB output in the column 'MetaPhlAn.taxon.names', | ||
#' returns a list of the microbes | ||
#' | ||
#' @param sig character string from bugsigDB output containing comma separated | ||
#' Metaphlan taxonomic names | ||
#' | ||
#' @return sig.list , a character list of containing the string after the last | ||
#' "|" in each comma separated Metaphlan taxonomic name | ||
#' | ||
#' @export | ||
getSigList <- function(sig){ | ||
sig.list <- sub("^.+\\|", "", unlist(strsplit(sig ,","))) | ||
return(sig.list) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#' Microbe Entries | ||
#' A function that can be used to call of specific microbe signatures. | ||
#' @param query Name of the signature group. If query is passed "all" function will return all the signature groups | ||
#' | ||
#' @return The microbes within a desired signature group in the format "x__microbe name" with x indicating taxonomic level | ||
#' @export | ||
#' | ||
#' @examples microbeEntries("paa_up") | ||
microbeEntries <- function(query){ | ||
|
||
paa_up <- c("s__Clostridium sp. UNK-MGS-6", "s__Firmicutes bacterium CAG 41", | ||
"s__Coprobacillus cateniformis", "s__Clostridia bacterium UC5-1-2G4", | ||
"s__Streptococcus dysgalactiae", "s__Acidaminococcus sp. HPA0509", | ||
"s__Roseburia sp.CAG-303", "s__Butyrivibrio_sp. AE2032", | ||
"s__Coprobacillus sp. 29-1", "s__Coprobacillus sp. D6") | ||
paa_down <- c("s__Alistipes sp. CAG-435", "s__Fusobacterium hwasookii", | ||
"s__Leuconostoc sp. DORA-2", "s__Paenibacillus lentimorbus", | ||
"s__Fusobacterium sp. oral taxon 370", "s__Alcanivorax hongdengensis", | ||
"s__Arthrobacter sp. LS16", "s__Bacillus sp. 5B6", "s__Bacillus velezensis", | ||
"s__Fusobacterium sp. OBRC1") | ||
|
||
mic_list <- list(paa_up, paa_down) | ||
|
||
names(mic_list) <- c("paa_up", "paa_down") | ||
|
||
if(query == "all"){ | ||
return(mic_list) | ||
} | ||
|
||
mics_queried <- mic_list[[query]] | ||
return(mics_queried) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# microsig | ||
This package contains functions to calculate microbe signatures, particularly from bugsigdb inputs. | ||
This package contains functions to calculate microbe signature scores, particularly from bugsigdb inputs. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: Sweave | ||
LaTeX: pdfLaTeX | ||
|
||
AutoAppendNewline: Yes | ||
StripTrailingWhitespace: Yes |