Editing the x and y axes of emperor plots

Hi there, I have generated bray curtis and weighted unifrac emperor plots and viewed in qiime2 view. But everytime I download the plot, the dimension of the axes are different( as shown in attached plot). The y axis in bray curtis is longer but in unifrac it is shorter. Is there a way to edit the x and y axes length in emperor plot?


Thanks
Man

@Man Emperor doesn't provide a way to modify the length of the axes. This is by design to ensure these values are kept unmodified. If you want to change these your best bet is to load the data in R/Python and play around with different x and y axis ranges, or to transform the coordinate spaces to fixed lengths.

For example in Python you would probably do something like:

import qiime2 as q2
from skbio import OrdinationResults
import seaborn as sns
import matplotlib.pyplot as plt

# try loading your sample metadata and PCoA matrix
metadata = q2.Metadata.load('mapping-file.tsv').to_dataframe()
unifrac = q2.Artifact.load('unweighted-unifrac.qza').view(OrdinationResults)

unifrac.samples.columns = [f'PC{i + 1} ({p * 100:.2f} %)' for i, p in enumerate(unifrac.proportion_explained)]
unifrac_w_metadata = unifrac.samples.merge(metadata, left_index=True, right_index=True)

# unifrac.samples contains the matrix of samples by PCoA dimensions in a Pandas DataFrame
# Use Seaborn or Matplotlib to generate a plot, for example (note you'll need to change the
# x, y and hue parameters to match your data:
ax = sns.scatterplot(x='PC1 (35.00 %)', y='PC2 (26.59 %)', hue='BodySite', data=unifrac_w_metadata)
ax.set_aspect('equal') # you might want to remove this line to play around with the aspect ratio
plt.savefig('plot.png')
2 Likes