phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
This is a minor issue, but since it toke me a while to find what was going on I decided to let you know:
I created a simple function to remove reads from negative controls by pcr batch, which looks as follows:
remove_NC<-function(phyloseq_tables, batch_id, NC_name){
### This functions removes the reads from NC of all samples from a given PCR batch
# returning a matrix of the otu table w/o the nc
### arguments:
## phyloseq_tables: a phyloseq object result of importing a taxonomy.biom file
## batch_id: character vector with the name of the batch ID. Asumes it exists in a variable
# "container_name" within the phyloseq tables
## NC_name: character vector with the name of the NC sample.
### Function:
# subset pcr batch
batch<- subset_samples(phyloseq_tables, container_name == batch_id)
print("input data looks like:")
print(batch)
## get otu matrix
batch_OTU<-as.matrix(otu_table(batch))
## get NC vector
NC<-as.vector(batch_OTU[,NC_name])
## Remove reads present in NC for each OTU
batch_clean<-batch_OTU-NC
## Repleace negative numbers with 0 since we can't have negative reads
batch_clean<-replace(batch_clean, batch_clean < 0, 0)
## tell the user what happened
print(paste("NC sample", NC_name, "was used to filter", sum(NC), "reads in total"))
## return results
batch_clean
}
The code of the function ran well if all if its arguments were created as objects, but if I tried running it providing the arguments as part of the function, like this:
Error in eval(e, x, parent.frame()) : objet 'batch_id' not found
After testing different things we realized that the issue was caused by subset_samples() not working unless everything it needs could be found in the global env.
I solved it adding batch_id <<- batch_id before calling subset_samples().
This solved the issue foe me, but I'm letting you know in case you find it worth fixing within subset_samples().
Hi,
This is a minor issue, but since it toke me a while to find what was going on I decided to let you know:
I created a simple function to remove reads from negative controls by pcr batch, which looks as follows:
The code of the function ran well if all if its arguments were created as objects, but if I tried running it providing the arguments as part of the function, like this:
Then I got the error:
After testing different things we realized that the issue was caused by
subset_samples()
not working unless everything it needs could be found in the global env.I solved it adding
batch_id <<- batch_id
before callingsubset_samples()
.This solved the issue foe me, but I'm letting you know in case you find it worth fixing within
subset_samples()
.Cheers,
Alicia