-
Notifications
You must be signed in to change notification settings - Fork 0
/
rbiom-deprecated.r
791 lines (618 loc) · 20.2 KB
/
rbiom-deprecated.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
## rbiom-deprecated.r
#' @name rbiom-deprecated
#' @title Deprecated functions in package \pkg{rbiom}.
#' @description The functions listed below are deprecated and will be defunct in
#' the near future. When possible, alternative functions with similar
#' functionality are also mentioned. Help pages for deprecated functions are
#' available at \code{help("<function>-deprecated")}.
#' @keywords internal
NULL
# Most functions have been renamed since last CRAN version. Reasons:
#
# * Use underscores instead of periods.
# * Better description of their purpose.
# * Combine near-duplicates.
#________________________________________________________
# Changes impacting users of CRAN's rbiom 1.0.3
#________________________________________________________
#' @name alpha.div-deprecated
#' @rdname rbiom-deprecated
#' @keywords internal
#' @section \code{alpha.div}:
#' Use [adiv_matrix()] or [adiv_table()] instead.
#' @export
alpha.div <- function (biom, rarefy = FALSE) {
deprecate_warn(
when = "2.0.0",
what = "alpha.div()",
details = "Please use `adiv_matrix()` or `adiv_table()` instead." )
biom <- as_rbiom(biom)
# Log intervals until rLvl/2, then even intervals until rLvl*2
if (eq(rarefy, "multi"))
rarefy <- local({
rLvl <- rare_suggest(biom)
rLvls <- 10 ** (c(1,3,5,7,8,9) * (log10(rLvl / 2) / 10))
rLvls <- c(rLvls, seq(from = rLvl / 2, to = rLvl * 2, length.out = 5))
rLvls <- floor(rLvls)
return (rLvls)
})
stopifnot(is_scalar_logical(rarefy) || is_integerish(rarefy))
res <- NULL
for (i in rarefy) {
df <- rarefy(biom, depth = i) %>%
adiv_matrix() %>%
as_tibble(x, rownames = 'Sample') %>%
as.data.frame()
if (length(rarefy == 1))
rownames(df) <- df[['Sample']]
res <- dplyr::bind_rows(res, df)
}
return (res)
}
# Depending on its arguments, beta.div() returned either a dist object or a
# data.frame. Now it's split into two functions - bdiv_distmat() which always
# returns a dist, and bdiv_table() which always returns a data.frame.
#' @name beta.div-deprecated
#' @rdname rbiom-deprecated
#' @section \code{beta.div}:
#' Use [bdiv_table()] or [bdiv_distmat()] instead.
#' @export
beta.div <- function (biom, method, weighted = TRUE, tree = NULL, long = FALSE, md = FALSE) {
if (isTRUE(long) || !isFALSE(md)) {
deprecate_warn(
when = "2.0.0",
what = "beta.div()",
details = "Please use `bdiv_table()` instead for generating a data.frame." )
if (isTRUE(md)) md <- ".all"
bdiv_table(biom = biom, bdiv = method, weighted = weighted, tree = tree, md = md)
} else {
deprecate_warn(
when = "2.0.0",
what = "beta.div()",
details = "Please use `bdiv_distmat()` instead for generating a distance matrix." )
bdiv_distmat(biom = biom, bdiv = method, weighted = weighted, tree = tree)
}
}
#' @name counts-deprecated
#' @rdname rbiom-deprecated
#' @section \code{counts}:
#' Use `$counts` instead.
#' @export
counts <- function (biom) {
deprecate_warn("2.0.0", "counts()", "otu_matrix()")
as.matrix(as_rbiom(biom)$counts)
}
#' @name info-deprecated
#' @rdname rbiom-deprecated
#' @section \code{info}:
#' Use `biom$id`, `biom$comment`, etc instead.
#' @export
info <- function (biom) {
deprecate_warn("2.0.0", "info()", "Use `biom$id`, `biom$comment`, etc instead.")
list(
id = biom$id,
comment = biom$comment,
date = biom$date,
generated_by = biom$generated_by,
format = "1.0.0",
type = "OTU table",
format_url = "http://biom-format.org",
matrix_type = "sparse",
matrix_element_type = ifelse(all(biom$counts[['v']] %% 1 == 0), "int", "float"),
shape = dim(biom$counts) )
}
#' @name metadata-deprecated
#' @rdname rbiom-deprecated
#' @section \code{metadata}:
#' Use `biom$metadata` or `pull(biom, field)` instead.
#' @export
metadata <- function (biom, field = NULL, cleanup = FALSE) {
deprecate_warn("2.0.0", "metadata()", "Use `biom$metadata` or `pull(biom, field)` instead.")
if (!missing(cleanup)) warning("`cleanup` is defunct")
biom <- as_rbiom(biom)
if (is.null(field)) biom$metadata else pull(biom = biom, field = field)
}
#' @name nsamples-deprecated
#' @rdname rbiom-deprecated
#' @section \code{nsamples}:
#' Use `biom$n_samples` instead.
#' @export
nsamples <- function (biom) {
deprecate_warn("2.0.0", "nsamples()", "biom$n_samples")
as_rbiom(biom)$n_samples
}
#' @name ntaxa-deprecated
#' @rdname rbiom-deprecated
#' @section \code{ntaxa}:
#' Use `biom$n_otus` instead.
#' @export
ntaxa <- function (biom) {
deprecate_warn("2.0.0", "ntaxa()", "biom$n_otus")
as_rbiom(biom)$n_otus
}
#' @name phylogeny-deprecated
#' @rdname rbiom-deprecated
#' @section \code{phylogeny}:
#' Use `biom$tree` instead.
#' @export
phylogeny <- function (biom) {
deprecate_warn("2.0.0", "phylogeny()", "biom$tree")
as_rbiom(biom)$tree
}
#' @name read.biom-deprecated
#' @rdname rbiom-deprecated
#' @section \code{read.biom}:
#' Use [as_rbiom()] instead.
#' @export
read.biom <- function (src, tree = "auto", prune = FALSE) {
deprecate_warn("2.0.0", "read.biom()", "as_rbiom()")
if (!missing(prune)) warning("`prune` argument is defunct")
biom <- as_rbiom(biom = src)
if (isTRUE(tree) && is.null(biom$tree))
cli_abort("Dataset does not include a phylogenetic tree.")
if (isTRUE(tree)) tree <- "auto"
if (isFALSE(tree)) tree <- NULL
if (!identical(tree, "auto"))
biom$tree <- tree
return (biom)
}
#' @name read.fasta-deprecated
#' @rdname rbiom-deprecated
#' @section \code{read.fasta}:
#' Use [read_fasta()] instead.
#' @export
read.fasta <- function (file, ids = NULL) {
deprecate_warn("2.0.0", "read.fasta()", "read_fasta()")
read_fasta(file = file, ids = ids)
}
#' @name read.tree-deprecated
#' @rdname rbiom-deprecated
#' @section \code{read.tree}:
#' Use [read_tree()] instead.
#' @export
read.tree <- function (src) {
deprecate_warn("2.0.0", "read.tree()", "read_tree()")
read_tree(src = src)
}
#' @name sample.names-deprecated
#' @rdname rbiom-deprecated
#' @section \code{sample.names}:
#' Use `biom$samples` instead.
#' @export
sample.names <- function (biom) {
deprecate_warn("2.0.0", "sample.names()", "biom$samples")
as_rbiom(biom)$samples
}
#' @name select-deprecated
#' @rdname rbiom-deprecated
#' @section \code{select}:
#' Use [slice()] instead.
#' @export
select.rbiom <- function (biom, samples = NULL, nTop = NULL, nRandom = NULL, seed = 0) {
deprecate_warn("2.0.0", "select()", "slice()")
biom <- biom$clone()
if (!is.null(samples)) biom$counts <- biom$counts[,samples]
if (!is.null(nTop)) biom$counts <- biom$counts[,names(head(sample_sums(biom), nTop))]
if (!is.null(nRandom)) {
set.seed(seed)
stopifnot(nRandom <= biom$n_samples)
biom$counts <- biom$counts[,sample(seq_len(ncol(biom$counts)), nRandom)]
}
return (biom)
}
#' @name sequences-deprecated
#' @rdname rbiom-deprecated
#' @section \code{sequences}:
#' Use `biom$sequences` instead.
#' @export
sequences <- function (biom) {
deprecate_warn("2.0.0", "sequences()", "biom$sequences")
as_rbiom(biom)$tree
}
#' @name subtree-deprecated
#' @rdname rbiom-deprecated
#' @section \code{subtree}:
#' Use [tree_subset()] instead.
#' @export
subtree <- function (tree, tips) {
deprecate_warn("2.0.0", "subtree()", "tree_subset()")
tree_subset(tree = tree, tips = tips)
}
#' @name taxa.names-deprecated
#' @rdname rbiom-deprecated
#' @section \code{taxa.names}:
#' Use `biom$otus` instead.
#' @export
taxa.names <- function (biom) {
deprecate_warn("2.0.0", "taxa.names()", "biom$otus")
as_rbiom(biom)$otus
}
#' @name taxa.ranks-deprecated
#' @rdname rbiom-deprecated
#' @section \code{taxa.ranks}:
#' Use `biom$ranks` instead.
#' @export
taxa.ranks <- function (biom) {
deprecate_warn("2.0.0", "taxa.ranks()", "biom$ranks")
as_rbiom(biom)$ranks
}
# Depending on its arguments, taxa.rollup() returned either a matrix or a
# data.frame. Now it's split into two functions - taxa_matrix() which always
# returns a matrix, and taxa_table() which always returns a data.frame.
#' @name taxa.rollup-deprecated
#' @rdname rbiom-deprecated
#' @section \code{taxa.rollup}:
#' Use [taxa_table()] [taxa_matrix()] instead.
#' @export
taxa.rollup <- function (
biom, rank = 'OTU', map = NULL, lineage = FALSE,
sparse = FALSE, taxa = NULL, long = FALSE, md = FALSE) {
if (!is.null(map)) {
biom <- as_rbiom(biom)$clone()
biom$taxonomy <- map
}
if (isTRUE(long) || !isFALSE(md)) {
deprecate_warn(
when = "2.0.0",
what = "taxa.rollup()",
details = "Please use `taxa_table()` instead for generating a data.frame." )
if (isTRUE(md)) md <- ".all"
taxa_table(
biom = biom,
rank = rank,
taxa = taxa,
lineage = lineage,
md = md )
} else {
deprecate_warn(
when = "2.0.0",
what = "beta.div()",
details = "Please use `taxa_matrix()` instead for generating a matrix." )
taxa_matrix(
biom = biom,
rank = rank,
taxa = taxa,
lineage = lineage,
sparse = sparse )
}
}
#' @name taxonomy-deprecated
#' @rdname rbiom-deprecated
#' @section \code{taxonomy}:
#' Use `$taxonomy` instead.
#' @export
taxonomy <- function (biom, ranks = NULL, unc = "asis") {
deprecate_warn("2.0.0", "taxonomy()", "Use `biom$taxonomy` or `taxa_map(biom, rank)` instead.")
biom <- as_rbiom(biom)
if (is.null(ranks)) biom$taxonomy else taxa_map(biom, ranks)
}
#' @name tips-deprecated
#' @rdname rbiom-deprecated
#' @section \code{tips}:
#' Use `tree$tip.label` instead.
#' @export
tips <- function (x) {
deprecate_warn("2.0.0", "tips()", "tree$tip.label")
validate_tree("x")
x$tip.label
}
#' @name unifrac-deprecated
#' @rdname rbiom-deprecated
#' @section \code{unifrac}:
#' Use [bdiv_distmat()] or [bdiv_table()] instead.
#' @export
unifrac <- function (biom, weighted=TRUE, tree=NULL) {
deprecate_soft("2.0.0", "unifrac()", "bdiv_distmat()")
bdiv_distmat(biom = biom, bdiv = "unifrac", weighted = weighted, tree = tree)
}
#' @name write.biom-deprecated
#' @rdname rbiom-deprecated
#' @section \code{write.biom}:
#' Use [write_biom()] instead.
#' @export
write.biom <- function (biom, file, format="json") {
deprecate_warn("2.0.0", "write.biom()", "write_biom()")
write_biom(biom = biom, file = file, format = format)
}
#' @name write.fasta-deprecated
#' @rdname rbiom-deprecated
#' @section \code{write.fasta}:
#' Use [write_fasta()] instead.
#' @export
write.fasta <- function (seqs, outfile = NULL) {
deprecate_warn("2.0.0", "write.fasta()", "write_fasta()")
write_fasta(biom = seqs, file = outfile)
}
#' @name write.tree-deprecated
#' @rdname rbiom-deprecated
#' @section \code{write.tree}:
#' Use [write_tree()] instead.
#' @export
write.tree <- function (tree, file = NULL) {
deprecate_warn("2.0.0", "write.tree()", "write_tree()")
write_tree(biom = tree, file = file)
}
#' @name write.xlsx-deprecated
#' @rdname rbiom-deprecated
#' @section \code{write.xlsx}:
#' Use [write_xlsx()] instead.
#' @export
write.xlsx <- function (biom, outfile, depth = NULL, seed = 0) {
deprecate_warn("2.0.0", "write.xlsx()", "write_xlsx()")
write_xlsx(biom = biom, file = outfile, depth = depth, seed = seed)
}
#________________________________________________________
# Changes impacting users of github's development version
#________________________________________________________
#' @name as.percent-deprecated
#' @rdname rbiom-deprecated
#' @section \code{as.percent}:
#' Use `biom$counts %<>% rescale_cols()` instead.
#' @export
as.percent <- function (biom) {
deprecate_warn(
when = "2.0.0",
what = "as.percent()",
details = "Please use `biom$counts %<>% rescale_cols()` instead." )
biom <- biom$clone()
biom$counts %<>% rescale_cols()
return (biom)
}
#' @name comments-deprecated
#' @rdname rbiom-deprecated
#' @section \code{comments}:
#' Use `biom$comment` instead.
#' @export
comments <- function (biom) {
deprecate_warn("2.0.0", "comments()", "biom$comment")
as_rbiom(biom)$comment
}
#' @name depth-deprecated
#' @rdname rbiom-deprecated
#' @section \code{depth}:
#' Use [sample_sums()] instead.
#' @export
depth <- function (biom) {
deprecate_warn("2.0.0", "depth()", "sample_sums()")
sample_sums(biom = biom)
}
#' @name depths_barplot-deprecated
#' @rdname rbiom-deprecated
#' @section \code{depths_barplot}:
#' Use [rare_stacked()] instead.
#' @export
depths_barplot <- function (biom, rline = TRUE, counts = TRUE, labels = TRUE, trans = "log10", ...) {
deprecate_warn("2.0.0", "depths_barplot()", "rare_stacked()")
rare_stacked(biom = biom, rline = rline, counts = counts, labels = labels, trans = trans, ...)
}
#' @name has.phylogeny-deprecated
#' @rdname rbiom-deprecated
#' @section \code{has.phylogeny}:
#' Use `!is.null(biom$tree)` instead.
#' @export
has.phylogeny <- function (biom) {
deprecate_warn("2.0.0", "has.phylogeny()", "!is.null(biom$tree)")
!is.null(as_rbiom(biom)$tree)
}
#' @name has.sequences-deprecated
#' @rdname rbiom-deprecated
#' @section \code{has.sequences}:
#' Use `!is.null(biom$sequences)` instead.
#' @export
has.sequences <- function (biom) {
deprecate_warn("2.0.0", "has.sequences()", "!is.null(biom$sequences)")
!is.null(as_rbiom(biom)$sequences)
}
#' @name id-deprecated
#' @rdname rbiom-deprecated
#' @section \code{id}:
#' Use `biom$id` instead.
#' @export
id <- function (biom) {
deprecate_warn("2.0.0", "id()", "biom$id")
as_rbiom(biom)$id
}
#' @name is.rarefied-deprecated
#' @rdname rbiom-deprecated
#' @section \code{is.rarefied}:
#' Use `!is.null(biom$depth)` instead.
#' @export
is.rarefied <- function (biom) {
deprecate_warn("2.0.0", "is.rarefied()", "!is.null(biom$depth)")
!is.null(as_rbiom(biom)$depth)
}
#' @name read_biom-deprecated
#' @rdname rbiom-deprecated
#' @section \code{read_biom}:
#' Use [as_rbiom()] instead.
#' @export
read_biom <- read.biom
#' @name repair-deprecated
#' @rdname rbiom-deprecated
#' @section \code{repair}:
#' Use [as_rbiom(as.list(biom))] instead.
#' @export
repair <- function (biom) {
deprecate_warn("2.0.0", "repair()", "as_rbiom(as.list(biom))")
as_rbiom(as.list(biom))
}
#' @name sample_subset-deprecated
#' @rdname rbiom-deprecated
#' @section \code{sample_subset}:
#' Use `biom$metadata %<>% base::subset()` instead.
#' @export
sample_subset <- function (x, ...) {
deprecate_warn("2.0.0", "sample_subset()", "subset()")
x <- x$clone()
x$metadata %<>% base::subset(...)
return (x)
}
#' @name sample.sums-deprecated
#' @rdname rbiom-deprecated
#' @section \code{sample.sums}:
#' Use [sample_sums()] or [adiv_table()] instead.
#' @export
sample.sums <- function (biom, long = FALSE, md = FALSE) {
if (isFALSE(long) && isFALSE(md)) {
deprecate_warn("2.0.0", "sample.sums()", "sample_sums()")
sample_sums(biom = biom)
} else {
deprecate_warn("2.0.0", "sample.sums()", "adiv_table()")
if (isTRUE(md)) md <- ".all"
if (isFALSE(md)) md <- NULL
adiv_table(biom = biom, md = md) %>%
dplyr::mutate(.keep = "none", Sample = .sample, Reads = .depth) %>%
as.data.frame()
}
}
# #' @name stats.table-deprecated
# #' @rdname rbiom-deprecated
# #' @section \code{stats.table}:
# #' Use [stats_table()] instead.
# #' @export
# stats.table <- function (...) {
# deprecate_warn("2.0.0", "stats.table()", "stats_table()")
# stats_table(...)
# }
#' @name taxa.means-deprecated
#' @rdname rbiom-deprecated
#' @section \code{taxa.means}:
#' Use [taxa_means()] instead.
#' @export
taxa.means <- function (biom, rank = NULL) {
deprecate_warn("2.0.0", "taxa.means()", "taxa_means()")
taxa_means(biom = biom, rank = rank)
}
#' @name taxa.sums-deprecated
#' @rdname rbiom-deprecated
#' @section \code{taxa.sums}:
#' Use [taxa_sums()] instead.
#' @export
taxa.sums <- function (biom, rank = NULL) {
deprecate_warn("2.0.0", "taxa.sums()", "taxa_sums()")
taxa_sums(biom = biom, rank = rank)
}
#' @name top.taxa-deprecated
#' @rdname rbiom-deprecated
#' @section \code{top.taxa}:
#' Use [taxa_sums()] instead.
#' @export
top.taxa <- function (biom, rank = 'OTU', n = Inf) {
deprecate_warn("2.0.0", "top.taxa()", "taxa_sums()")
names(head(taxa_sums(biom, rank), n))
}
#' @name top_taxa-deprecated
#' @rdname rbiom-deprecated
#' @section \code{top_taxa}:
#' Use [taxa_sums()] instead.
#' @export
top_taxa <- function (biom, rank = 'OTU', n = Inf) {
deprecate_warn("2.0.0", "top_taxa()", "taxa_sums()")
names(head(taxa_sums(biom, rank), n))
}
#' @name comments-set-deprecated
#' @rdname rbiom-deprecated
#' @section \code{comments-set}:
#' Use [$comment] instead.
#' @export
`comments<-` <- function (x, value) {
deprecate_warn("2.0.0", "comments()", "$comment")
x$comment <- value
}
#' @name counts-set-deprecated
#' @rdname rbiom-deprecated
#' @section \code{counts-set}:
#' Use [$counts] instead.
#' @export
`counts<-` <- function (x, value) {
deprecate_warn("2.0.0", "counts()", "$counts")
x$counts <- value
}
#' @name id-set-deprecated
#' @rdname rbiom-deprecated
#' @section \code{id-set}:
#' Use [$id] instead.
#' @export
`id<-` <- function (x, value) {
deprecate_warn("2.0.0", "id()", "$id")
x$id <- value
}
#' @name metadata-set-deprecated
#' @rdname rbiom-deprecated
#' @section \code{metadata-set}:
#' Use [$metadata] instead.
#' @export
`metadata<-` <- function (x, value) {
deprecate_warn("2.0.0", "metadata()", "$metadata")
x$metadata <- value
}
#' @name phylogeny-set-deprecated
#' @rdname rbiom-deprecated
#' @section \code{phylogeny-set}:
#' Use [$tree] instead.
#' @export
`phylogeny<-` <- function (x, value) {
deprecate_warn("2.0.0", "phylogeny()", "$tree")
x$tree <- value
}
#' @name sample.names-set-deprecated
#' @rdname rbiom-deprecated
#' @section \code{sample.names-set}:
#' @export
`sample.names<-` <- function (x, value) {
deprecate_warn("2.0.0", "sample.names()")
stopifnot(isa(x, "rbiom"))
stopifnot(is.character(value))
stopifnot(length(value) == ncol(x$counts))
b <- as.list(x)
colnames(b$counts) <- value
b$metadata[['.sample']] <- value
if (!is.null(b$sequences))
names(b$sequences) <- value
as_rbiom(b)
}
#' @name sequences-set-deprecated
#' @rdname rbiom-deprecated
#' @section \code{sequences-set}:
#' Use [otu_sequences()] instead.
#' @export
`sequences<-` <- function (x, value) {
deprecate_warn("2.0.0", "sequences()", "$sequences")
x$sequences <- value
}
#' @name taxa.names-set-deprecated
#' @rdname rbiom-deprecated
#' @section \code{taxa.names-set}:
#' @export
`taxa.names<-` <- function (x, value) {
deprecate_warn("2.0.0", "taxa.names()")
stopifnot(isa(x, "rbiom"))
stopifnot(is.character(value))
stopifnot(length(value) == nrow(x$counts))
b <- as.list(x)
if (!is.null(b$tree))
b$tree$tip.label <- value[match(rownames(b$counts), b$tree$tip.label)]
rownames(b$counts) <- value
b$taxonomy[['.otu']] <- value
as_rbiom(b)
}
#' @name taxa.ranks-set-deprecated
#' @rdname rbiom-deprecated
#' @section \code{taxa.ranks-set}:
#' @export
`taxa.ranks<-` <- function (x, value) {
deprecate_warn("2.0.0", "taxa.ranks()")
df <- x$taxonomy
colnames(df) <- value
x$taxonomy <- df
return (x)
}
#' @name taxonomy-set-deprecated
#' @rdname rbiom-deprecated
#' @section \code{taxonomy-set}:
#' Use [$taxonomy] instead.
#' @export
`taxonomy<-` <- function (x, value) {
deprecate_warn("2.0.0", "taxonomy()", "$taxonomy")
x$taxonomy <- value
}