Dear @jbisanz@Nicholas_Bokulich,
I'm also following the qiime2R tutorial. But in the step of creating a point and line plot. I have errors, and I'm not understanding how to solve this.
And the shannon_vector.qza file is, shannon_vector.qza (160.5 KB)
after running the following code,
shannon<-read_qza("core-metrics-results/shannon_vector.qza")
#Code for moving the sample names to a new column that matches the metadata sample_id
shannon<-shannon$data %>% rownames_to_column("SampleID")
#This allows shannon and metadata to be merged
head(shannon)
Now the problem is when I'm trying to run the following code,
metadata %>%
filter(!is.na(shannon)) %>%
ggplot(aes(x=`Age [sample]`, y=shannon, color=`BMI_class [sample]`)) +
stat_summary(geom="errorbar", fun.data=mean_se, width=0) +
stat_summary(geom="line", fun.data=mean_se) +
stat_summary(geom="point", fun.data=mean_se) +
xlab("AGE") +
ylab("Shannon Diversity") +
theme_q2r() + # try other themes like theme_bw() or theme_classic()
scale_color_viridis_d(name="BMI") # use different color scale which is color blind friendly
ggsave("Shannon_by_time.pdf", height=3, width=4, device="pdf") # save a PDF 3 inches by 4 inches
the error showing is this,
Error in `filter()`:
ℹ In argument: `!is.na(shannon)`.
Caused by error:
! `..1` must be a logical vector, not a logical matrix.
Backtrace:
1. metadata %>% filter(!is.na(shannon)) %>% ...
10. dplyr:::dplyr_internal_error(...)
Dear @jbisanz@Nicholas_Bokulich,
I'm also following the qiime2R tutorial. But in the step of creating a point and line plot. I have errors, and I'm not understanding how to solve this.
And the shannon_vector.qza file is, shannon_vector.qza (160.5 KB)
after running the following code,
shannon<-read_qza("core-metrics-results/shannon_vector.qza")
#Code for moving the sample names to a new column that matches the metadata sample_id
shannon<-shannon$data %>% rownames_to_column("SampleID")
#This allows shannon and metadata to be merged
head(shannon)
Now the problem is when I'm trying to run the following code,
metadata %>%
filter(!is.na(shannon)) %>%
ggplot(aes(x=`Age [sample]`, y=shannon, color=`BMI_class [sample]`)) +
stat_summary(geom="errorbar", fun.data=mean_se, width=0) +
stat_summary(geom="line", fun.data=mean_se) +
stat_summary(geom="point", fun.data=mean_se) +
xlab("AGE") +
ylab("Shannon Diversity") +
theme_q2r() + # try other themes like theme_bw() or theme_classic()
scale_color_viridis_d(name="BMI") # use different color scale which is color blind friendly
ggsave("Shannon_by_time.pdf", height=3, width=4, device="pdf") # save a PDF 3 inches by 4 inches
the error showing is this,
Error in `filter()`:
ℹ In argument: `!is.na(shannon)`.
Caused by error:
! `..1` must be a logical vector, not a logical matrix.
Backtrace:
1. metadata %>% filter(!is.na(shannon)) %>% ...
10. dplyr:::dplyr_internal_error(...)
Please do not post twice. We read all the posts anyway. (It's also against our code of conduct.)
The error is from that second line of your code:
metadata %>%
filter(!is.na(shannon)) %>%
Here, the metadata data.frame is being filtered by rows. Rows are only kept in the data.frame if the $shannon column is not NA. The issue is that your metadata dataframe does not have a column called shannon. You do have another data.frame called shannon.
I would merge those two dataframes together and see how they look. Then filter by the shannon column.
Let us know if you have any questions about how to do this.