def community_plot( tree: str, table: str, sample_metadata: str, output_dir: str, pcoa: str, feature_metadata: str, ignore_missing_samples: bool, filter_extra_samples: bool, filter_missing_features: bool, number_of_pcoa_features: int, shear_to_table: bool, ) -> None: tree_newick, fm = check_and_process_files(output_dir, tree, feature_metadata) table = load_table(table) sample_metadata = pd.read_csv(sample_metadata, sep="\t", index_col=0) if pcoa is not None: pcoa = OrdinationResults.read(pcoa) pcoa = prepare_pcoa(pcoa, number_of_pcoa_features) viz = Empress( tree_newick, table=table, sample_metadata=sample_metadata, feature_metadata=fm, ordination=pcoa, ignore_missing_samples=ignore_missing_samples, filter_extra_samples=filter_extra_samples, filter_missing_features=filter_missing_features, shear_to_table=shear_to_table, ) os.makedirs(output_dir) save_viz(viz, output_dir, q2=False)
def tree_plot(output_dir: str, tree: NewickFormat, feature_metadata: qiime2.Metadata = None) -> None: """Visualizes a tree (optionally with feature metadata).""" if feature_metadata is not None: feature_metadata = feature_metadata.to_dataframe() t = get_bp(tree) viz = Empress(tree=t, feature_metadata=feature_metadata) save_viz(viz, output_dir)
def tree_plot( tree: str, output_dir: str, feature_metadata: str, shear_to_feature_metadata: bool, ) -> None: tree_newick, fm = check_and_process_files(output_dir, tree, feature_metadata) viz = Empress(tree_newick, feature_metadata=fm, shear_to_feature_metadata=shear_to_feature_metadata) os.makedirs(output_dir) save_viz(viz, output_dir, q2=False)
def community_plot(output_dir: str, tree: NewickFormat, feature_table: biom.Table, sample_metadata: qiime2.Metadata, pcoa: OrdinationResults = None, feature_metadata: qiime2.Metadata = None, ignore_missing_samples: bool = False, filter_extra_samples: bool = False, filter_missing_features: bool = False, number_of_features: int = 5, shear_tree: bool = True) -> None: """Visualizes a tree alongside community-level data. The functionality available in this visualization is a superset of the functionality in tree_plot() -- including sample metadata coloring / barplots, animations, and Emperor integration support. """ if pcoa is not None and pcoa.features is not None: # select the top N most important features based on the vector's # magnitude (coped from q2-emperor) feats = pcoa.features.copy() # in cases where the axes are all zero there might be all-NA # columns feats.fillna(0, inplace=True) origin = np.zeros_like(feats.columns) feats['importance'] = feats.apply(euclidean, axis=1, args=(origin, )) feats.sort_values('importance', inplace=True, ascending=False) feats.drop(['importance'], inplace=True, axis=1) pcoa.features = feats[:number_of_features].copy() sample_metadata = sample_metadata.to_dataframe() if feature_metadata is not None: feature_metadata = feature_metadata.to_dataframe() t = get_bp(tree) viz = Empress(tree=t, table=feature_table, sample_metadata=sample_metadata, feature_metadata=feature_metadata, ordination=pcoa, ignore_missing_samples=ignore_missing_samples, filter_extra_samples=filter_extra_samples, filter_missing_features=filter_missing_features, shear_tree=shear_tree) save_viz(viz, output_dir)
def community_plot(output_dir: str, tree: NewickFormat, feature_table: biom.Table, sample_metadata: qiime2.Metadata, pcoa: OrdinationResults = None, feature_metadata: qiime2.Metadata = None, ignore_missing_samples: bool = False, filter_extra_samples: bool = False, filter_missing_features: bool = False, number_of_features: int = 5, shear_to_table: bool = True) -> None: """Visualizes a tree alongside community-level data. The functionality available in this visualization is a superset of the functionality in tree_plot() -- including sample metadata coloring / barplots, animations, and Emperor integration support. """ if pcoa is not None and pcoa.features is not None: pcoa = prepare_pcoa(pcoa, number_of_features) sample_metadata = sample_metadata.to_dataframe() if feature_metadata is not None: feature_metadata = feature_metadata.to_dataframe() t = get_bp(tree) viz = Empress(tree=t, table=feature_table, sample_metadata=sample_metadata, feature_metadata=feature_metadata, ordination=pcoa, ignore_missing_samples=ignore_missing_samples, filter_extra_samples=filter_extra_samples, filter_missing_features=filter_missing_features, shear_to_table=shear_to_table) save_viz(viz, output_dir)