assign-sample_data: Assign (new) sample_data to 'x'

Description Usage Arguments Value Examples

Description

This replaces the current sample_data component of x with value, if value is a sample_data-class. However, if value is a data.frame, then value is first coerced to a sample_data-class, and then assigned. Alternatively, if value is phyloseq-class, then the sample_data component will first be accessed from value and then assigned. This makes possible some concise assignment/replacement statements when adjusting, modifying, or building subsets of experiment-level data. See some examples below.

Internally, this re-builds the phyloseq-class object using the standard phyloseq constructor. Thus, index mismatches between sample-describing components will not be allowed, and subsetting will occurr automatically such that only the intersection of sample IDs are included in any components. This has the added benefit of re-checking (internally) for any other issues.

Usage

1
sample_data(x) <- value

Arguments

x

(Required). phyloseq-class. The object to modify.

value

(Required). Either a sample_data-class, a data.frame that can be coerced into sample_data-class, or a phyloseq-class that contains a suitable sample_data component to assign to x. If unsure, try sample_data(value), which should return a sample_data-class object without error.

Value

No return. This is an assignment statement.

Examples

1
2
3
4
5

Example output

phyloseq-class experiment-level object
otu_table()   OTU Table:         [ 16825 taxa and 56 samples ]
sample_data() Sample Data:       [ 56 samples by 4 sample variables ]
Sample Data:        [6 samples by 4 sample variables]:
       Treatment warmed clipped Sample
a_C026        UC     no     yes    6CC
a_C066        UU     no      no    3UC
a_C070        WU    yes      no    5UW
a_C074        UU     no      no    2UC
a_C075        WC    yes     yes    5CW
a_C077        WU    yes      no    4UW
Sample Data:        [6 samples by 5 sample variables]:
       Treatment warmed clipped Sample Time
a_C026        UC     no     yes    6CC    6
a_C066        UU     no      no    3UC    3
a_C070        WU    yes      no    5UW    5
a_C074        UU     no      no    2UC    2
a_C075        WC    yes     yes    5CW    5
a_C077        WU    yes      no    4UW    4
Warning message:
system call failed: Cannot allocate memory 

phyloseq documentation built on Nov. 8, 2020, 6:41 p.m.