assign-sample_names: Replace OTU identifier names

Description Usage Arguments Examples

Description

Replace OTU identifier names

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
sample_names(x) <- value

## S4 replacement method for signature 'ANY,ANY'
sample_names(x) <- value

## S4 replacement method for signature 'ANY,character'
sample_names(x) <- value

## S4 replacement method for signature 'otu_table,character'
sample_names(x) <- value

## S4 replacement method for signature 'sample_data,character'
sample_names(x) <- value

## S4 replacement method for signature 'phyloseq,character'
sample_names(x) <- value

Arguments

x

(Required). An object defined by the phyloseq-package that describes OTUs in some way.

value

(Required). A character vector to replace the current sample_names.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
data("esophagus")
sample_names(esophagus)
# plot_tree(esophagus, color="sample_names", ladderize="left")
sample_names(esophagus) <- paste("Sa-", sample_names(esophagus), sep="")
sample_names(esophagus)
# plot_tree(esophagus, color="sample_names", ladderize="left") 
## non-characters are first coerced to characters.
sample_names(esophagus) <- 1:nsamples(esophagus)
sample_names(esophagus)
# plot_tree(esophagus, color="sample_names", ladderize="left") 
## Cannot assign non-unique or differently-lengthed name vectors. Error.
# sample_names(esophagus) <- sample(c(TRUE, FALSE), nsamples(esophagus), TRUE)
# sample_names(esophagus) <- sample(sample_names(esophagus), nsamples(esophagus)-1, FALSE)

Example output

[1] "B" "C" "D"
[1] "Sa-B" "Sa-C" "Sa-D"
[1] "1" "2" "3"
Warning message:
system call failed: Cannot allocate memory 

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