Commit d69aa8f4 authored by Midoux Cedric's avatar Midoux Cedric

CLR transfo (retours OC)

parent b501b52c
...@@ -300,13 +300,13 @@ output$transformFun <- renderText({ ...@@ -300,13 +300,13 @@ output$transformFun <- renderText({
sep = "\n"), sep = "\n"),
"sqrt" = "data_sqrt <- transform_sample_counts(data, sqrt)", "sqrt" = "data_sqrt <- transform_sample_counts(data, sqrt)",
"clr" = paste("gm_mean <- function(x, na.rm=TRUE) {", "clr" = paste("gm_mean <- function(x, na.rm=TRUE) {",
" exp(sum(log(x[x > 0 & !is.na(x)]), na.rm=na.rm) / length(x))", " return(exp(mean(log(x), na.rm=na.rm)))",
" }",
"clr <- function(x, base=2) {",
" x <- log((x / gm_mean(x)), base)",
" x[!is.finite(x) | is.na(x)] <- 0.0",
" return(x)",
"}", "}",
"clr <- function(x, base=exp(1)) {",
" x <- x+1",
" x <- log(x/gm_mean(x), base)",
" return(x)",
"}",
"data_clr <- transform_sample_counts(data, clr)", "data_clr <- transform_sample_counts(data, clr)",
sep = "\n") sep = "\n")
) )
...@@ -328,11 +328,11 @@ observeEvent(input$transformData, { ...@@ -328,11 +328,11 @@ observeEvent(input$transformData, {
}, },
"clr" = { "clr" = {
gm_mean <- function(x, na.rm=TRUE) { gm_mean <- function(x, na.rm=TRUE) {
exp(sum(log(x[x > 0 & !is.na(x)]), na.rm=na.rm) / length(x)) return(exp(mean(log(x), na.rm=na.rm)))
} }
clr <- function(x, base=2) { clr <- function(x, base=exp(1)) {
x <- log((x / gm_mean(x)), base) x <- x+1
x[!is.finite(x) | is.na(x)] <- 0.0 x <- log(x/gm_mean(x), base)
return(x) return(x)
} }
physeq(transform_sample_counts(physeq(), clr)) physeq(transform_sample_counts(physeq(), clr))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment