faith_pd_vector error in QIIME2r_V2 column

I recently started analyzing data with qiime2-2022.8. To get alpha/beta diversity I ran the "qiime diversity core-metrics-phylogenetic" code. First columns of medata file
Metadata_YMKB_1.txt (918 Bytes)
attached...

qiime diversity core-metrics-phylogenetic \
  --i-phylogeny rooted-tree.qza \
  --i-table prepost-table.qza \
  --p-sampling-depth 21224  \
  --m-metadata-file Metadata_YMKB_1.txt \
  --output-dir a_prepost/prepost-core-metrics-results/prepost-core-metrics-resultstype or 

I also created .qzv files for faith_pd, shannon, and evenness data. These files looked fine. I have utilized @jbisanz very useful tutorial to visualize data in R: Tutorial: Integrating QIIME2 and R for data visualization and analysis using qiime2R

However, when I tried to create plots with faith_pd alpha diversity, I ran into errors. The issue is that faithpd (but not shannon or evenness) is an object with 3 variables. My SampleID column is a numerical list (not ID names) and my ID names are on the second column labelled "V2" with faith_pd data in a "V3" column. In the past, I've only had my ID names and also my "faith_pd" column. I don't have this issue with other alpha diversity .qza files. Has anyone run into this issue? If so, is there a work-around?

Thank you!
K

faithpd1 <-read_qza("faith_pd_vector.qza")$data %>% rownames_to_column("SampleID")
shannon <-read_qza("shannon_vector.qza")$data %>% rownames_to_column("SampleID")
evenness <-read_qza("evenness_vector.qza")$data %>% rownames_to_column("SampleID")

1 Like

Welcome to the forums, @KBauer,

Looks like the FaithPD table has a slightly different format, so you will have to use R to make the columns match.

The function rownames_to_column() takes the dataframe's row names, and turns them into a normal column inside the dataframe. This appears to work well for the Shannon and and Evenness objects, where the rowname is the SampleID. After running rownames_to_column(), the SampleID is a column inside the dataframe next to the diversity values.

For the FaithPD object, the SampleID is already in the dataframe, so running rownames_to_column() on this object adds an extra column. Try importing the FaithPD object without calling this function afterwards.

Hi,
I had exactly the same problem with the same qiime2-2022.8 version. I tried to use the data frame without calling the function row names_to_column (as suggested by @colinbrislawn) but it didn't work.

So I tried this and it worked (probably not the best way to do it because I'm new to R!!):

faith_pd <- read_qza("core-metrics-results/Diversity_Alpha/faith_pd_vector.qza")
faith_pd <- faith_pd$data %>% rownames_to_column("SampleID")
faith_pd <- faith_pd[,-1]
colnames(faith_pd) <- c('SampleID', 'faith_pd')

1 Like

Thank you @LCFortier! I did something similar and this works great :slight_smile:
Happy 2023

1 Like