Skip to content

Commit

Permalink
update new mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
noriakis committed Feb 7, 2024
1 parent 0918c2d commit c41a2ad
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 10 deletions.
19 changes: 14 additions & 5 deletions R/doGSEA.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,25 @@ L2FC <- function(mat, l1, l2, method="t", eps=0) {
#' @param stana stana object
#' @param candSp candidate species ID
#' @param how how to summarize multiple gene CN assigned to the same KO
#' @param annot eggNOG or manual
#' @export
calcKO <- function(stana, candSp=NULL, how=sum) {
calcKO <- function(stana, candSp=NULL, how=sum, annot="eggNOG") {
checkID(stana, candSp)
if (is.null(candSp)) {cat("Species not specified, the first ID will be used:", stana@ids[1]);
candSp <- stana@ids[1]
}
if (is.null(stana@eggNOG[[candSp]])) {stop("Please provide list of path to annotation file by `setAnnotation` function.")}
ko_df_filt <- summariseAbundance(stana, sp = candSp,
checkEGGNOG(annot_file=stana@eggNOG[[candSp]], "KEGG_ko"),
how=how)
if (annot=="eggNOG") {
if (is.null(stana@eggNOG[[candSp]])) {stop("Please provide list of path to annotation file by `setAnnotation` function.")}
ko_df_filt <- summariseAbundance(stana, sp = candSp,
checkEGGNOG(annot_file=stana@eggNOG[[candSp]], "KEGG_ko"),
how=how)
} else {
if (is.null(stana@map[[candSp]])) {stop("Please set mapping data.frame in map slot using `setMap`.")}
ko_df_filt <- summariseAbundance(stana, sp = candSp,
stana@map[[candSp]],
how=how)
}

stana@kos[[candSp]] <- ko_df_filt
stana
}
Expand Down
21 changes: 20 additions & 1 deletion R/stana.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#' @slot kos stores ko table
#' @slot type type of pipeline, such as `MIDAS`
#' @slot eggNOG list of path for eggNOG mapper v2 results for species
#' @slot map slot storing the mapping data.frame for gene ID and orthology
setClass("stana", slots=list(
type="character",
cl="list",
Expand Down Expand Up @@ -45,7 +46,8 @@ setClass("stana", slots=list(
colors="vector",
geneCluster="list",
paFilterUp="numeric",
paFilterDown="numeric"))
paFilterDown="numeric",
map="list"))
setMethod("show",
signature(object="stana"),
function(object) {
Expand Down Expand Up @@ -155,6 +157,23 @@ setAnnotation <- function(stana, annotList) {
return(stana)
}


#' setMap
#' @param stana stana object
#' @param candSp species ID
#' @param map mapping data.frame, two column consisting of ID and value.
#' The function internally changes the column name.
#' ID is gene ID in `genes` slot, and value indicates orthology ID (like K00001)
#' @export
#' @return stana object
setMap <- function(stana, candSp, map) {
if (dim(map)[2]!=2) {stop("Please provide two-column data.frame")}
colnames(map) <- c("ID", "value")
stana@map[[candSp]] <- map
return(stana)
}


#' getColors
#' @import RColorBrewer
#' @noRd
Expand Down
7 changes: 5 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ stana <- stana |>
inferAndPlotTree(meta=c("treatment","marker"))
getFasta(stana)[[1]]
getTree(stana)[[1]]
getSlot(stana, "treePlotList")[[1]]
getTreePlot(stana)[[1]]
```

If the gene copy number table is available like in `MIDAS` series and `inStrain`, one can compare the functional implications of these gene contents.


## Interactive inspection

The users can inspect metagenotyping results interactively using Shiny based on the variables such as disease conditions (`exportInteractive()`).
The users can inspect metagenotyping results interactively using Shiny based on the variables such as disease conditions (`exportInteractive()`). One can publish the results in the hosting services for sharing the research findings.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ stana <- setMetadata(stana, metadata)
## Infer and plot tree based on metadata
stana <- stana |>
consensusSeq(argList=list(site_prev=0.95)) |>
plotTree(meta=c("treatment","marker"))
inferAndPlotTree(meta=c("treatment","marker"))
#> Beginning calling for 100003
#> Site number: 5019
#> Profiled samples: 11
Expand All @@ -85,7 +85,7 @@ getTree(stana)[[1]]
#> ERR1711593, ERR1711594, ERR1711596, ERR1711598, ERR1711603, ERR1711605, ...
#>
#> Unrooted; includes branch lengths.
getSlot(stana, "treePlotList")[[1]]
getTreePlot(stana)[[1]]
```

<img src="man/figures/README-unnamed-chunk-2-1.png" width="1800" style="display: block; margin: auto;" />
Expand Down

0 comments on commit c41a2ad

Please sign in to comment.