@@ -1767,55 +1767,63 @@ select_one_sample <- function(physeq, sam_name, silent = FALSE) {
1767
1767
# ' Note that if trainingSet is not NULL, the ref_fasta is overwrite by the
1768
1768
# ' trainingSet parameter. To customize learning parameters of the idtaxa
1769
1769
# ' algorithm you must use trainingSet computed by the function [learn_idtaxa()].
1770
- # ' @param min_boostrap (Int. \[0:1\])
1771
- # '
1770
+ # ' @param min_bootstrap (Int. \[0:1\])
1771
+ # '
1772
1772
# ' Minimum bootstrap value to inform taxonomy. For each bootstrap
1773
- # ' below the min_boostrap value, the taxonomy information is set to NA.
1774
- # '
1773
+ # ' below the min_bootstrap value, the taxonomy information is set to NA.
1774
+ # '
1775
1775
# ' Correspond to parameters :
1776
- # '
1776
+ # '
1777
1777
# ' - dada2: `minBoot`, default value = 0.5
1778
- # '
1779
- # ' - sintax: `min_boostrap`, default value = 60
1780
- # '
1781
- # ' - lca: `threshold`, default value = 60
1782
- # '
1783
- # ' - idtaxa: `threshold`, default value = 60
1784
- # '
1778
+ # '
1779
+ # ' - sintax: `min_bootstrap`, default value = 0.5
1780
+ # '
1781
+ # ' - lca: `id`, default value = 0.5. Note in that case, the bootstrap value is different.
1782
+ # ' See the id parameter in [assign_vsearch_lca()]
1783
+ # '
1784
+ # ' - idtaxa: `threshold`, default value = 0.6
1785
+ # '
1785
1786
# ' @param ... Other arguments passed on to the taxonomic assignation method.
1786
1787
# ' @return A new \code{\link[phyloseq]{phyloseq-class}} object with a larger slot tax_table"
1787
1788
# ' @seealso [dada2::assignTaxonomy()], [assign_sintax()], [assign_vsearch_lca()], [assign_sintax()]
1788
1789
# ' @export
1789
1790
# '
1790
1791
# ' @author Adrien Taudière
1791
1792
# '
1792
- add_new_taxonomy_pq <- function (physeq , ref_fasta , suffix = NULL , method = c(" dada2" , " sintax" , " lca" , " idtaxa" ), trainingSet = NULL , min_boostrap = NULL , ... ) {
1793
+ add_new_taxonomy_pq <- function (
1794
+ physeq ,
1795
+ ref_fasta ,
1796
+ suffix = NULL ,
1797
+ method = c(" dada2" , " sintax" , " lca" , " idtaxa" ),
1798
+ trainingSet = NULL ,
1799
+ min_bootstrap = NULL ,
1800
+ ... ) {
1793
1801
method <- match.arg(method )
1794
1802
1795
- if (is.null(min_boostrap )) {
1796
- min_boostrap <- ifelse(method == " idtaxa" , 0.6 , 0.5 )
1803
+ if (is.null(min_bootstrap )) {
1804
+ min_bootstrap <- ifelse(method == " idtaxa" , 0.6 , 0.5 )
1797
1805
}
1798
1806
1799
1807
if (is.null(suffix )) {
1800
1808
suffix <- paste0(" _" , basename(ref_fasta ), " _" , method )
1801
1809
}
1802
1810
if (method == " dada2" ) {
1803
1811
tax_tab <-
1804
- dada2 :: assignTaxonomy(physeq @ refseq , refFasta = ref_fasta , minBoot = 100 * min_boostrap , ... )
1812
+ dada2 :: assignTaxonomy(physeq @ refseq , refFasta = ref_fasta , minBoot = 100 * min_bootstrap , ... )
1805
1813
colnames(tax_tab ) <-
1806
1814
make.unique(paste0(colnames(tax_tab ), suffix ))
1807
1815
new_tax_tab <- tax_table(cbind(physeq @ tax_table , tax_tab ))
1808
1816
new_physeq <- physeq
1809
1817
tax_table(new_physeq ) <- new_tax_tab
1810
1818
} else if (method == " sintax" ) {
1811
- new_physeq <- assign_sintax(physeq , ref_fasta = ref_fasta , suffix = suffix , behavior = " add_to_phyloseq" , min_boostrap = min_boostrap , ... )
1819
+ new_physeq <- assign_sintax(physeq , ref_fasta = ref_fasta , suffix = suffix , behavior = " add_to_phyloseq" , min_bootstrap = min_bootstrap , ... )
1812
1820
} else if (method == " lca" ) {
1813
1821
new_physeq <- assign_vsearch_lca(physeq , ref_fasta = ref_fasta , suffix = suffix , behavior = " add_to_phyloseq" , ... )
1814
1822
} else if (method == " idtaxa" ) {
1815
1823
if (is.null(trainingSet )) {
1816
- new_physeq <- assign_idtaxa(physeq , seq2search = ref_fasta , suffix = suffix , threshold = 100 * min_boostrap , ... )
1824
+ new_physeq <- assign_idtaxa(physeq , fasta_for_training = ref_fasta , behavior = " add_to_phyloseq " , suffix = suffix , threshold = 100 * min_bootstrap , ... )
1817
1825
} else {
1818
- new_physeq <- assign_idtaxa(physeq , trainingSet = trainingSet , suffix = suffix , ... )
1826
+ new_physeq <- assign_idtaxa(physeq , trainingSet = trainingSet , behavior = " add_to_phyloseq " , suffix = suffix , threshold = 100 * min_bootstrap , ... )
1819
1827
}
1820
1828
}
1821
1829
@@ -1927,7 +1935,8 @@ tbl_sum_taxtable <- function(physeq, taxonomic_ranks = NULL, ...) {
1927
1935
# '
1928
1936
# ' @inheritParams clean_pq
1929
1937
# ' @param taxLevels Name of the 7 columns in tax_table required by funguild
1930
- # '
1938
+ # ' @param db_url a length 1 character string giving the URL to retrieve the database
1939
+ # ' from
1931
1940
# ' @return A new object of class `physeq` with Guild information added to
1932
1941
# ' `tax_table` slot
1933
1942
# ' @export
@@ -1952,7 +1961,7 @@ tbl_sum_taxtable <- function(physeq, taxonomic_ranks = NULL, ...) {
1952
1961
# ' @details
1953
1962
# ' This function is mainly a wrapper of the work of others.
1954
1963
# ' Please make a reference to `FUNGuildR` package and the associate
1955
- # ' publication (\doi{10.1016/j.funeco.2015.06.006}) if you
1964
+ # ' publication (\doi{doi: 10.1016/j.funeco.2015.06.006}) if you
1956
1965
# ' use this function.
1957
1966
# ' @seealso [plot_guild_pq()]
1958
1967
@@ -1965,13 +1974,18 @@ add_funguild_info <- function(physeq,
1965
1974
" Family" ,
1966
1975
" Genus" ,
1967
1976
" Species"
1968
- )) {
1977
+ ),
1978
+ db_url = " http://www.stbates.org/funguild_db_2.php" ) {
1969
1979
tax_tab <- physeq @ tax_table
1970
1980
FUNGuild_assign <-
1971
1981
funguild_assign(data.frame (
1972
1982
" Taxonomy" =
1973
1983
apply(tax_tab [, taxLevels ], 1 , paste , collapse = " ;" )
1974
- ))
1984
+ ), db_url = db_url )
1985
+ if (is.null(FUNGuild_assign )) {
1986
+ message(" No http access to the funguild database. No information were added." )
1987
+ return (physeq )
1988
+ }
1975
1989
tax_tab <-
1976
1990
as.matrix(cbind(tax_tab , FUNGuild_assign ))
1977
1991
physeq @ tax_table <- tax_table(tax_tab )
@@ -3156,6 +3170,11 @@ rarefy_sample_count_by_modality <-
3156
3170
# '
3157
3171
# ' - "add_to_phyloseq" return a phyloseq object with amended slot `@taxtable`.
3158
3172
# ' Only available if using physeq input and not seq2search input.
3173
+ # ' @param threshold (Int, default 60) Numeric specifying the confidence at which
3174
+ # ' to truncate the output taxonomic classifications.
3175
+ # ' Lower values of threshold will classify deeper into the taxonomic tree at
3176
+ # ' the expense of accuracy, and vise-versa for higher values of threshold. See
3177
+ # ' [DECIPHER::IdTaxa()] man page.
3159
3178
# ' @param column_names (vector of character) names for the column of the
3160
3179
# ' taxonomy
3161
3180
# ' @param suffix (character) The suffix to name the new columns.
@@ -3199,11 +3218,12 @@ rarefy_sample_count_by_modality <-
3199
3218
assign_idtaxa <- function (physeq ,
3200
3219
seq2search = NULL ,
3201
3220
trainingSet = NULL ,
3202
- fasta_for_training ,
3221
+ fasta_for_training = NULL ,
3203
3222
behavior = " return_matrix" ,
3223
+ threshold = 60 ,
3204
3224
column_names = c(
3205
3225
" Kingdom" ,
3206
- " Phyla " ,
3226
+ " Phylum " ,
3207
3227
" Class" ,
3208
3228
" Order" ,
3209
3229
" Family" ,
@@ -3215,7 +3235,11 @@ assign_idtaxa <- function(physeq,
3215
3235
unite = FALSE ,
3216
3236
verbose = TRUE ,
3217
3237
... ) {
3218
- if (is.null(trainingSet ) && ! is.null(fasta_for_training )) {
3238
+ if (! is.null(trainingSet ) && ! is.null(fasta_for_training )) {
3239
+ stop(" Please provide either trainingSet or fasta_for_training parameters, not both." )
3240
+ } else if (is.null(trainingSet ) && is.null(fasta_for_training )) {
3241
+ stop(" Please provide either trainingSet or fasta_for_training parameters." )
3242
+ } else if (is.null(trainingSet ) && ! is.null(fasta_for_training )) {
3219
3243
if (verbose ) {
3220
3244
message(" Training using fasta_for_training file." )
3221
3245
}
@@ -3230,7 +3254,7 @@ assign_idtaxa <- function(physeq,
3230
3254
return_DNAStringSet = TRUE
3231
3255
)
3232
3256
3233
- fasta2search <- OrientNucleotides(RemoveGaps(fasta2search ))
3257
+ fasta2search <- DECIPHER :: OrientNucleotides(DECIPHER :: RemoveGaps(fasta2search ))
3234
3258
3235
3259
if (verbose ) {
3236
3260
message(" Classifing using training Set with IdTaxa." )
@@ -3240,6 +3264,7 @@ assign_idtaxa <- function(physeq,
3240
3264
test = fasta2search ,
3241
3265
trainingSet = trainingSet_idtaxa ,
3242
3266
processors = nproc ,
3267
+ threshold = threshold ,
3243
3268
...
3244
3269
)
3245
3270
@@ -3352,9 +3377,9 @@ assign_idtaxa <- function(physeq,
3352
3377
# ' Please make a reference to [DECIPHER::LearnTaxa()] if you
3353
3378
# ' use this function.
3354
3379
learn_idtaxa <- function (fasta_for_training , output_Rdata = NULL , output_path_only = FALSE , unite = FALSE , ... ) {
3355
- seqs <- readDNAStringSet(fasta_for_training )
3356
- seqs <- RemoveGaps(seqs )
3357
- seqs <- OrientNucleotides(seqs )
3380
+ seqs <- Biostrings :: readDNAStringSet(fasta_for_training )
3381
+ seqs <- DECIPHER :: RemoveGaps(seqs )
3382
+ seqs <- DECIPHER :: OrientNucleotides(seqs )
3358
3383
3359
3384
taxo_for_learning <- names(seqs )
3360
3385
if (unite ) {
@@ -3374,7 +3399,7 @@ learn_idtaxa <- function(fasta_for_training, output_Rdata = NULL, output_path_on
3374
3399
taxo_for_learning [! grepl(" ^Root;" , taxo_for_learning )] <-
3375
3400
paste0(" Root;" , taxo_for_learning [! grepl(" ^Root;" , taxo_for_learning )])
3376
3401
3377
- train_idtaxa <- LearnTaxa(seqs , taxonomy = taxo_for_learning , ... )
3402
+ train_idtaxa <- DECIPHER :: LearnTaxa(seqs , taxonomy = taxo_for_learning , ... )
3378
3403
if (! is.null(output_Rdata )) {
3379
3404
save(train_idtaxa , output_Rdata )
3380
3405
}
0 commit comments