#!/usr/bin/env python # coding: utf-8 # TODO: # - sampling statistics # # In[1]: get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') # In[2]: from microbiome.dataset import MicrobiomeDataset from microbiome.trajectory import MicrobiomeTrajectory import pandas as pd # In[3]: dataset = MicrobiomeDataset(file_name="human_data") # In[4]: from microbiome.enumerations import TimeUnit # In[5]: trajectory = MicrobiomeTrajectory(dataset, dataset.feature_columns) # In[6]: trajectory.time_unit = TimeUnit.YEAR # In[7]: results = trajectory.plot_reference_trajectory() results["fig"] # In[8]: trajectory.time_unit = TimeUnit.DAY # In[9]: results = trajectory.plot_reference_trajectory(degree=1) results["fig"] # In[11]: # human dataset doesn't have reference and non-reference # results = trajectory.plot_reference_groups() # results["fig"] # In[13]: # human dataset doesn't have reference and non-reference # results = trajectory.plot_reference_groups(degree=1) # results["fig"] # In[14]: trajectory.dataset.df.group.value_counts() # In[15]: l = trajectory.dataset.df.group.value_counts().index.values[:2] l # In[16]: results = trajectory.plot_groups() results["fig"] # In[17]: results = trajectory.plot_groups(degree=1) results["fig"] # In[18]: results["ret_val"] # In[19]: from microbiome.enumerations import AnomalyType # In[20]: results = trajectory.plot_anomalies(anomaly_type=AnomalyType.PREDICTION_INTERVAL) results['fig'] # In[21]: results = trajectory.plot_anomalies(anomaly_type=AnomalyType.LOW_PASS_FILTER) results['fig'] # In[22]: results = trajectory.plot_anomalies(anomaly_type=AnomalyType.ISOLATION_FOREST) results['fig']#.write_html("file.html") # In[23]: results = trajectory.plot_timeboxes(layout_settings=dict(hoverdistance=None), time_block_ranges=[10,10,10,10,10, 10, 20]) results['fig'] # In[24]: results = trajectory.plot_animated_longitudinal_information() results["fig"] # In[26]: from microbiome.enumerations import FeatureExtraction # In[27]: dataset.normalized = True trajectory = MicrobiomeTrajectory(dataset, dataset.feature_columns, feature_extraction=FeatureExtraction.NEAR_ZERO_VARIANCE) trajectory.feature_columns_plot # In[28]: dataset.normalized = False trajectory = MicrobiomeTrajectory(dataset, dataset.feature_columns, feature_extraction=FeatureExtraction.NEAR_ZERO_VARIANCE) trajectory.feature_columns_plot # In[29]: dataset.normalized = True trajectory = MicrobiomeTrajectory(dataset, dataset.feature_columns, feature_extraction=FeatureExtraction.CORRELATION) trajectory.feature_columns_plot # In[30]: dataset.normalized = False trajectory = MicrobiomeTrajectory(dataset, dataset.feature_columns, feature_extraction=FeatureExtraction.CORRELATION) trajectory.feature_columns_plot # In[31]: dataset.normalized = True trajectory = MicrobiomeTrajectory(dataset, dataset.feature_columns, feature_extraction=FeatureExtraction.TOP_K_IMPORTANT) trajectory.feature_columns_plot # In[32]: dataset.normalized = False trajectory = MicrobiomeTrajectory(dataset, dataset.feature_columns, feature_extraction=FeatureExtraction.TOP_K_IMPORTANT) trajectory.feature_columns_plot # In[33]: from microbiome.dataset import ReferenceGroup,FeatureColumnsType # In[34]: dataset = MicrobiomeDataset(file_name="human_data", feature_columns=FeatureColumnsType.BACTERIA_AND_METADATA) trajectory = MicrobiomeTrajectory(dataset, dataset.feature_columns) # In[35]: dataset.normalized = True trajectory = MicrobiomeTrajectory(dataset, dataset.feature_columns, feature_extraction=FeatureExtraction.TOP_K_IMPORTANT) trajectory.feature_columns_plot # In[ ]: