Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Doc: Feature Filtering

kmorrisongr edited this page Feb 17, 2020 · 2 revisions

Exclude An Attribute

fcff_exclude_attr(fc, attr, clm)

  • Exclude an attribute from an Fc Array data frame.
  • @param fc The Fc Array data frame.
  • @param attr The value of the thing you want gone.
  • @param clm What column in fc attr will be found in.
  • @return The Fc Array data frame, without the rows that have values in clm matching attr.
  • @examples
fc_no_plac = fcff_exclude_attr(fc, "PLACEBO", "group")

Filter Features By Difference From Baseline

fcff_feats_diff(fc, diff_opts)

  • Filter features from an Fc Array data frame by their difference from baseline.
  • @param fc The Fc Array data frame.
  • @param diff_opts A list containing the following sub-parameters:
    • diff_opts$base_ids Uhe row indices in fc that correspond to the subjects who represent baseline (say, those in the PLACEBO group).
    • diff_opts$test Which statistical test to use to determine difference from baseline.
    • diff_opts$alternative Alternative hypothesis (two.sided, either (two.sided/2)).
    • diff_opts$adj_method The method you want to use to adjust p-values. Use "none" as a passthrough.
  • @return The p-values that represent the comparison between baseline and the other subjects using the test specified in diff_opts.
  • @examples
p_vals = fcff_feats_diff(fc, diff_opts)
keep = p_vals < 0.05

Filter Features

fcff_filter_features(fc, feats, action, behavior="permissive", diff_opts=NULL)

  • Filter features based on keyword. You can keep those, remove those, and many other things.
  • @param fc The Fc Array data frame.
  • @param feats Vector of strings for the features you want to keep or remove.
  • @param action String specifying whether you want to "keep" or "toss" the features in feats.
  • @param behavior Whether the feature names will be matched by:
    • containing any of the strings in feats ("permissive").
    • containing all of the strings in feats ("strict").
    • Alternatively, "differs" specifies that features will be removed by difference from baseline. This will be done instead of keyword filtering (so to do both, call this function twice).
  • @param diff_opts list of options if behavior = "differs". see ?fcff_feats_diff.
  • @return The Fc Array data frame filtered based on what you specified.
  • @examples
new_fc = fcff_filter_features(fc, c("gp41", "gp120"), "keep")
my_diff_opts = list() # fill with stuff
diff_fc = fccu_filter_features(fc, NULL, NULL, behavior="differs", diff_opts=my_diff_opts)

Keep Only Specific Values Of A Column

fcff_only_attr(fc, attr, attrs, clm)

  • A wrapper for fcff_exclude_attr that performs the exclusion behavior repeatedly in order to produce a dataset with just attr in attrs.
  • @param fc The Fc Array data frame.
  • @param attr The value of the thing you want gone.
  • @param attrs A vector containing all the values that attr can take on in clm.
  • @param clm What column in fc attr will be found in.
  • @return The Fc Array data frame, with only the rows that have values in clm matching attr.
  • @examples
groups = c("PLACEBO", "VACCINE")
fc_only_placebo = fcff_only_attr(fc, "PLACEBO", groups, "group")

Remove Correlated Features

fcff_remove_cor(fc, cutoff, behavior="sample")

  • Remove correlated features from fc based on cutoff.
  • @param fc The Fc Array data frame.
  • @param cutoff The correlation coefficient cutoff above which we will remove features from fc.
  • @param behavior How we'll decide what to keep as a representative feature from those to be removed. "sample" randomly selects one feature. "first" picks the first one in the list.
  • @return The Fc Array data frame filtered based on what you specified.

Higher-Level Interface For Filtering Features

fcff_wrap_filter(fc, results_dir, keep_filter, discard_filter, k_behavior, d_behavior, diff_opts="NULL")

  • Filter features in such a way as to set up experiments. Will filter feautres/perform fcff_feats_diff as necessary, and will create files/directories (as necessary) to facilitate result reproduction and keep different versions of fc analysis sequestered.
  • @param fc The Fc Array data frame
  • @param results_dir A string representing the directory where you want to store the results of your analyses.
  • @param keep_filter A vector of strings of features that you want to retain in fc. If no keeping is to be done, pass an empty vector c().
  • @param discard_filter A vector of strings of features that you want to remove from fc. If no discarding is to be done, pass an empty vector c().
  • @param k_behavior A string "permissive" or "strict" controlling keeping behavior. Can also be set to "differs" to perform fcff_feats_diff. See ?fcff_filter_features for more.
  • @param d_behavior A string "permissive" or "strict" controlling discarding behavior. Can also be set to "differs" to perform fcff_feats_diff. See ?fcff_filter_features for more.
  • @param diff_opts A list of subparameters for fcff_feats_diff. Pass "NULL" if you don't want to do any fcu_feats_diff things. See ?fcu_feats_diff for more.
  • @return A list containing the filtered Fc Array data frame (accessed by $fc), and the new results_dir string based on the filtering performed (accessed by $results_dir). If both keeping and discarding are performed, results_dir will be of the form complex_YYYYMMDD_HHMMSS, and the directory will contain a txt file with the filtering that was performed.
  • @examples
results_dir = "/home/me/science/experiments/"
filtered = fcff_wrap_filter(fc, results_dir, c("gp41", "gp120"), c(), "permissive", "NULL")
fc = filtered$fc
# is now "/home/me/science/experiments/only_gp41_gp120"
results_dir = filtered$results_dir

Clone this wiki locally