R/filter_pident.R

Defines functions filter_pident

Documented in filter_pident

#' @title filter_pident
#' @name filter_pident
#' @description This function filters BLAST-like tabular output according to
#' protein identity.
#' @param rbh BLAST-like tabular matrix [mandatory]
#' @param pident percent identity [default: 0.0]
#' @param inverse specify if filter should keep the removed values
#' [default: FALSE]
#' @return rbh matrix
#' @importFrom dplyr filter
#' @examples
#' ## load crbh data
#' data(ath_aly_crbh)
#' dim(ath_aly_crbh$crbh1)
#' dim(filter_pident(
#'     rbh=ath_aly_crbh$crbh1,
#'     pident=75))
#' @export filter_pident
#' @author Kristian K Ullrich

filter_pident <- function(rbh,
    pident=0.0,
    inverse=FALSE
    ){
    perc_identity <- NULL
    if(inverse){
        #return(rbh[as.numeric(rbh[,3])<pident, , drop=FALSE])
        return(dplyr::filter(rbh, perc_identity<pident))
    } else {
        #return(rbh[as.numeric(rbh[,3])>=pident, , drop=FALSE])
        return(dplyr::filter(rbh, perc_identity>=pident))
    }
}
kullrich/CRBHits documentation built on March 29, 2024, 11:34 a.m.