Alpha diversity graphics from qiime to R error

Hey guys,

I'm trying to use qza files to generate alpha diversity graphics from qiime2 to R but this part is returning an error:

adiv <- data.frame("observed_features" = read_qza("../core-metrics-results/observed_features_vector.qza")$data,
                   "shannon" = read_qza("../core-metrics-results/shannon_vector.qza")$data,
                   "evenness" = read_qza("../core-metrics-results/evenness_vector.qza")$data,
                   "faith_pd" = read_qza("../core-metrics-results/faith_pd_vector.qza")$data$V2,
                   "chao1" = read_qza("../core-metrics-results/chao1_vector.qza")$data,
                   "simpson" = read_qza("../core-metrics-results/simpson_vector.qza")$data,
                   "Status" = phyloseq::sample_data(ps)$Treatment, 
                   check.names = FALSE)
colnames(adiv) <- c("Observed", "Shannon", "Evenness", "Faith_pd", "Chao1", "Simpson", "Group")
head(adiv)

The following error is returned:

Error in data.frame(observed_features = read_qza("..t/core-metrics-results/observed_features_vector.qza")$data, :
arguments imply differing number of rows: 77, 79

Although, I already saw the number of rows and lines and they are exactly the same (except for faith pdf, which is why when reading the dataframe it is used only column 2 by "$data$V2" option.

So I don't know what it can be or how to fix this..

nrow(observed_features_data)
[1] 77
length(observed_features_data)
[1] 1
nrow(shannon_vector)
[1] 77
length(shannon_vector)
[1] 1
nrow(evenness)
[1] 77
length(evenness)
[1] 1
nrow(faith_pd)
[1] 77
length(faith_pd)
[1] 2
nrow(chao1)
[1] 77
length(chao1)
[1] 1
nrow(simpson)
[1] 77
length(simpson)
[1] 1

Hi @Liviacmg,
Thank you for bring this up! This is an error that we are trying to fix. Here is the github issue if you would like to track progress: After 2022.8 faith_pd_vector.qza comes with a #SampleID index/column name · Issue #57 · qiime2/q2-diversity-lib · GitHub

Basically this issue is that the faith pd vector is being output as a "dataframe" whose columns are ID and Faith PD. All the other metrics are series and they only have the "metric" column. If you grab the second column of the faith's PD output that will be comparable to the other metrics!

Hope that helps!
:turtle:

1 Like

Hi @cherman2 ,

Thank you for the reply! Althought, I tried removing faith pd just to check and the error is still returned. :frowning:

That is weird.
I think you should try eliminating each alpha diversity vector (like you did with faith's pd) so that we can see which one is the culprit :mag:

That should give us a better idea of what is going on!

1 Like

Hi @cherman2 ,

I only saw now that the metadata had 79 samples and the metrics had 77. I uploaded the wrong metadata file... thank you so much for your help :sweat_smile:

2 Likes