R: Main function for data filtering

repFilter {immunarch} | R Documentation

## Main function for data filtering

### Description

Main function for data filtering

### Usage

    repFilter(
      .data,
      .method = "by.clonotype",
      .query = list(CDR3.aa = exclude("partial", "out_of_frame")),
      .match = "exact"
    )

### Arguments

`.data` | The data to be processed. Must be the list of 2 elements: data table and metadata table.
`.method` | Method of filtering. Implemented methods: by.meta, by.repertoire (by.rep), by.clonotype (by.cl) Default value: 'by.clonotype'.
`.query` | Filtering query. It's a named list of filters that will be applied to data. Possible values for names in this list are dependent on filter methods: - by.meta: filter by metadata. Names in the named list are metadata column headers. - by.repertoire: filter by number of clonotypes or total number of clones in sample. Possible names in the named list are "n_clonotypes" and "n_clones". - by.clonotype: filter by data in all samples. Names in the named list are data column headers. Elements of the named list for each of the filters are filtering options. Possible values for filtering options: - include("STR1", "STR2", ...): keep only rows with matching values. Available for methods: "by.meta", "by.clonotype". - exclude("STR1", "STR2", ...): remove rows with matching values. Available for methods: "by.meta", "by.clonotype". - lessthan(value): keep rows/samples with numeric values less than specified. Available for methods: "by.meta", "by.repertoire", "by.clonotype". - morethan(value): keep rows/samples with numeric values more than specified. Available for methods: "by.meta", "by.repertoire", "by.clonotype". - interval(from, to): keep rows/samples with numeric values that fits in this interval. from is inclusive, to is exclusive. Available for methods: "by.meta", "by.repertoire", "by.clonotype". Default value: 'list(CDR3.aa = exclude("partial", "out_of_frame"))'.
`.match` | Matching method for "include" and "exclude" options in query. Possible values: - exact: match only the exact specified string; - startswith: match all strings starting with the specified substring; - substring: match all strings containing the specified substring. Default value: 'exact'.

### Examples

    data(immdata)

    # Select samples with status "MS"
    repFilter(immdata, "by.meta", list(Status = include("MS")))

    # Select samples without status "MS"
    repFilter(immdata, "by.meta", list(Status = exclude("MS")))

    # Select samples from lanes "A" and "B" with age > 15
    repFilter(immdata, "by.meta", list(Lane = include("A", "B"), Age = morethan(15)))

    # Select samples that are not from lanes "A" and "B"
    repFilter(immdata, "by.meta", list(Lane = exclude("A", "B")))

    # Select samples with a number of clonotypes from 1000 to 5000
    repFilter(immdata, "by.repertoire", list(n_clonotypes = interval(1000, 5000)))

    # Select clonotypes in all samples with alpha chains
    repFilter(immdata, "by.clonotype",
      list(V.name = include("AV"), J.name = include("AJ")),
      .match = "substring"
    )

[Package immunarch version 0.6.7 Index]