presenceGrpFilt: Filter for each group of columns for sufficient data as...

View source: R/presenceGrpFilt.R

presenceGrpFiltR Documentation

Filter for each group of columns for sufficient data as non-NA

Description

The aim of this function is to filter for each group of columns for sufficient data as non-NA.

Usage

presenceGrpFilt(dat, grp, presThr = 0.75, silent = FALSE, callFrom = NULL)

Arguments

dat

matrix or data.frame (abundance or expression-values which may contain some NAs).

grp

factor of min 2 levels describing which column of 'dat' belongs to which group (levels 1 & 2 will be used)

presThr

(numeric) min ratio of non- NA values (per group) for returning a given line & group as TRUE

silent

(logical) suppress messages

callFrom

(character) allow easier tracking of messages produced

Details

This function allows to identify lines with an NA-content above the threshold presThr per group as defined by the levels of factor grp. With different types of projects/questions different threshold presThr levels may be useful. For example, if one would like to keep the degree of threshold presThrs per group rather low, one could use a value of 0.75 (ie >= 75

Value

logical matrix (with on column for each level of grp)

See Also

presenceFilt, there are also other packages totaly dedicated to filtering on CRAN and Bioconductor

Examples

 mat <- matrix(NA, nrow=11, ncol=6)
 mat[lower.tri(mat)] <- 1
 mat <- cbind(mat, mat[,1:4])
 colnames(mat) <- c(paste0("re",1:6), paste0("x",1:4))
 mat[6:8,7:10] <- mat[1:3,7:10]  # ref
 mat[9:11,1:6] <- mat[2:4,1:6]

##  accept 1 NA out of 4, 2 NA out of 6   (ie certainly present)
 (filt0a <- presenceGrpFilt(mat, rep(1:2, c(6,4)), pres=0.66))
##  accept 2 NA out of 4, 2 NA out of 6   (ie min 50% present)
 (filt0b <- presenceGrpFilt(mat, rep(1:2, c(6,4)), pres=0.5))
##  accept 3 NA out of 4, 4 NA out of 6   (ie possibly present)
 (filt0c <- presenceGrpFilt(mat, rep(1:2, c(6,4)), pres=0.19))


wrMisc documentation built on Sept. 11, 2024, 6:10 p.m.