Skip to content

Commit

Permalink
update new function for dwtus
Browse files Browse the repository at this point in the history
  • Loading branch information
yufree committed Sep 25, 2019
1 parent 0c1f90f commit 2806fb5
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Expand Up @@ -17,6 +17,7 @@ export(getcsv)
export(getdata)
export(getdata2)
export(getdoe)
export(getdwtus)
export(getfeaturesanova)
export(getfeaturest)
export(getfilter)
Expand Down Expand Up @@ -45,6 +46,7 @@ export(getupload3)
export(gifmr)
export(ma)
export(plotden)
export(plotdwtus)
export(plote)
export(plotgroup)
export(plothist)
Expand Down
14 changes: 14 additions & 0 deletions R/getmzrt.R
Expand Up @@ -629,3 +629,17 @@ getoverlaprt <- function(rtrange1, rtrange2) {
index <- (!is.na(overlapms))
return(index)
}
#' Density weighted intensity for one sample
#' @param peak peaks intensity one sample
#' @param n the number of equally spaced points at which the density is to be estimated, default 512
#' @param log log transformation
#' @return Density weighted intensity for one sample
#' @export
#'
getdwtus <- function(peak,n=512,log=F){
if(log){
peak <- log(peak+1)
}
sum <- sum(density(peak,bw='sj',n=n)$x*density(peak,bw='sj',n=n)$y)
return(sum)
}
19 changes: 19 additions & 0 deletions R/plotmzrt.R
Expand Up @@ -760,3 +760,22 @@ plotridges <- function(data, lv, type = "g") {
bins = 100) + ggplot2::xlim(-0.5, 0.5) + ggplot2::scale_fill_discrete(name = "Group") +
ggplot2::labs(x = "Relative Log Abundance", y = "Samples")
}
#' plot density weighted intensity for multiple samples
#' @param list list with data as peaks list, mz, rt and group information
#' @param n the number of equally spaced points at which the density is to be estimated, default 512
#' @param ... parameters for `plot` function
#' @return Density weighted intensity for multiple samples
#' @examples
#' data(list)
#' plotdwtus(list)
#' @export
plotdwtus <- function(list,n=512,...){
dwtus <- apply(list$data, 2, function(x) getdwtus(x,n = n))
if(!is.null(list$order)){
plot(dwtus~as.numeric(list$order), xlab='Run order', ylab = 'DWTUS', col = as.numeric(as.factor(list$group)),...)
legend('topright',legend = unique(list$group),col = unique(as.numeric(as.factor(list$group))),pch = 19,bty = 'n')
}else{
plot(dwtus~as.numeric(as.factor(list$group)),xlab='Group', ylab = 'DWTUS',col = as.numeric(as.factor(list$group)),...)
legend('topright',legend = unique(list$group),col = unique(as.numeric(as.factor(list$group))),pch = 19,bty = 'n')
}
}
21 changes: 21 additions & 0 deletions man/getdwtus.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions man/plotdwtus.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2806fb5

Please sign in to comment.