Hi,
I’m trying to get the bar plots by subsetting different variables (diet, gender, timepoint, family (Ruminococcaceae) in fefifo study as I’m looking into how has the abundance of this taxa changed over the course of the study ( from baseline ( timepoint 2) to choice period (timepoint 9)
I’m aiming to get separate plots for both timepoints. My code is below. The error that shows up says family not found. Any comments are appreciated
fefifo_subset_F_2_Fermented_Taxa<-subset_samples(fefifo, gender==“Female”|timepoint==“2”|diet==“Fermented”|Family == "Ruminococcaceae ")
plot_bar (fefifo_subset_F_2_Fermented_Taxa, x= “gender”, fill = “Family”, title = “Family across Female (Fermented only at timepoint 2(Baseline))”) +
geom_bar(aes(color = Family, fill = Family), stat=“identity”, position = “stack”)
@ksgeorge95 does it work if you remove the space before the ending quote?
Family == "Ruminococcaceae "
h/t @JennKerr
I’ll have my student give it a try. For some reason she wasn’t able to login to the online community.
Thanks for your help!
@ksgeorge95 I finally got a chance to look at the code and run it on AnVIL. There are a few issues.
In the first line you have to specify the taxa subset first and then within that subset, you will then subset_samples. You have to use a & instead of the | to connect multiple subsets. If you specify the single time point like 9, it just makes one column, since only female was chosen, at a single timepoint, for a single diet.
# Subset
my_subset <- subset_samples(fefifo, gender == "Female" & timepoint == "9" & diet == "Fermented")
my_subset <- subset_taxa(my_subset, Family == "Ruminococcaceae")
#Plotting using the new subset
plot_bar(my_subset, x= "gender", fill = "Family", title = "Family across Female: Fermented only at timepoint 9") +
geom_bar(aes(color = Family, fill = Family), stat = "identity", position = "stack")+
facet_wrap(~timepoint)
Instead you may want to consider using the facet_wrap that will allow all of the time points to be shown.
# Subset
my_subset <- subset_samples(fefifo, gender == "Female" & diet == "Fermented")
my_subset <- subset_taxa(my_subset, Family == "Ruminococcaceae")
#Plotting using the new subset
plot_bar(my_subset, x= "gender", fill = "Family", title = "Ruminococcaceae Family in Females with Fermented Diet") +
geom_bar(aes(color = Family, fill = Family), stat = "identity", position = "stack")+
facet_wrap(~timepoint)
@JennKerr. Thanks for the feedback! I’ll pass this along to my student. Your help is greatly appreciated.