filter_dm_by_NA_in_metadata: filter_dm_by_NA_in_metadata

View source: R/DistSplit.R

filter_dm_by_NA_in_metadataR Documentation

filter_dm_by_NA_in_metadata

Description

filter_dm_by_NA_in_metadata

Usage

filter_dm_by_NA_in_metadata(dm, metadata, target_field, ids_col = NA)

Arguments

dm

A squared distance matrix or a 'dist' object.

metadata

A dataframe with > two columns corresponds to samples (rownames) in the distance matrix.

target_field

A metadata variable corresponds to samples in the distance matrix and used for filtering the distance matrix.

ids_col

A string indicates the sample ID column in the metadata

Author(s)

Shi Huang

Examples

set.seed(123)
x <- data.frame(rbind(t(rmultinom(7, 75, c(.201,.5,.02,.18,.099))),
            t(rmultinom(8, 75, c(.201,.4,.12,.18,.099))),
            t(rmultinom(15, 75, c(.011,.3,.22,.18,.289))),
            t(rmultinom(15, 75, c(.091,.2,.32,.18,.209))),
            t(rmultinom(15, 75, c(.001,.1,.42,.18,.299)))))
x0 <- data.frame(rbind(t(rmultinom(7, 75, c(.011,.3,.22,.18,.289))),
            t(rmultinom(8, 75, c(.011,.3,.22,.18,.289))),
            t(rmultinom(15, 75, c(.011,.3,.22,.18,.289))),
            t(rmultinom(15, 75, c(.011,.3,.22,.18,.289))),
            t(rmultinom(15, 75, c(.011,.3,.22,.18,.289)))))
y<-factor(c(rep("A", 29), NA, rep("B", 29), NA))
z<-factor(c(rep("A", 20), rep("B", 20), rep("C", 20)))
metadata<-data.frame(y, z)
dm<-dist(x)
filter_dm_by_NA_in_metadata(dm, metadata, target_field="y")

shihuang047/DistVis documentation built on Jan. 9, 2023, 10:39 p.m.