#* Copyright (C) 2018 the DEUS contributors.
#* Website: https://github.com/timjeske/DEUS
#*
#* This file is part of the DEUS R package.
#*
#* The DEUS R package is free software: you can redistribute it and/or modify
#* it under the terms of the GNU General Public License as published by
#* the Free Software Foundation, either version 3 of the License, or
#* (at your option) any later version.
#*
#* This program is distributed in the hope that it will be useful,
#* but WITHOUT ANY WARRANTY; without even the implied warranty of
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#* GNU General Public License for more details.
#*
#* You should have received a copy of the GNU General Public License
#* along with this program. If not, see <http://www.gnu.org/licenses/>.
#' Compute fraction of reads without BLAST hit for each sample
#'
#' @param summary Summary table generated by \link[DEUS]{mergeResults} (requires BLAST result generated by \link[DEUS]{runBlast})
#' @param count_table A table of (normalized) sequence counts.
#' A sequence count table can be generated by \link[DEUS]{createCountTableFromFastQs} and normalized by applying \link[DEUS]{runDESeq2}
#' @return A data frame with samples as row names and the column 'NA_fraction'
#' @export
getNoBlastHitFraction <- function(summary, count_table) {
if(!("FeatureList" %in% names(summary))) stop('Feature classes can only be counted if blast results have been merged to DE results!')
minql <- min(summary[summary$FeatureList!="NA",]$Length, na.rm=T)
summary <- summary[summary$Length >= minql,]
select <- row.names(summary)[summary$FeatureList=="NA"]
sub <- count_table[as.vector(select),,drop = FALSE]
res <- colSums(sub)/colSums(count_table)
res <- as.data.frame(res)
colnames(res) <- c("NA_fraction")
return(res)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.