Skip to content

Commit

Permalink
deprecating all visualization functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mortonjt committed Jul 8, 2021
1 parent 93cd506 commit c619b1b
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 13 deletions.
4 changes: 4 additions & 0 deletions gneiss/plot/_decompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import matplotlib.pyplot as plt
import pandas as pd
from gneiss.util import NUMERATOR, DENOMINATOR
import warning


def balance_boxplot(balance_name, data, num_color='#FFFFFF',
Expand Down Expand Up @@ -49,6 +50,7 @@ def balance_boxplot(balance_name, data, num_color='#FFFFFF',
--------
seaborn.boxplot
"""
warnings.warn("This visualization are deprecated.", DeprecationWarning)
import seaborn as sns
if ax is None:
f, ax = plt.subplots()
Expand Down Expand Up @@ -118,6 +120,7 @@ def balance_barplots(tree, balance_name, header, feature_metadata,
ax_denom : matplotlib axes object
Barplot of the features in the denominator of the balance.
"""
warnings.warn("This visualization are deprecated.", DeprecationWarning)
import seaborn as sns
if axes[0] is None or axes[1] is None:
f, (ax_num, ax_denom) = plt.subplots(2)
Expand Down Expand Up @@ -238,6 +241,7 @@ def proportion_plot(table, metadata, category, left_group, right_group,
Since this method will return the raw matplotlib object, labels, titles,
ticks, etc can directly modified using this object.
"""
warnings.warn("This visualization are deprecated.", DeprecationWarning)
import seaborn as sns
if axes[0] is None or axes[1] is None:
f, (ax_num, ax_denom) = plt.subplots(1, 2)
Expand Down
1 change: 1 addition & 0 deletions gneiss/plot/_heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ def _plot_heatmap(ax_heatmap, table, mdvar, grid_col,
colorbar_ax : matplotlib axes object
The colorbar axis.
"""
warnings.warn("This visualization are deprecated.", DeprecationWarning)
# TODO add explicit test for this, since matplotlib orientation
# is from top to down (i.e. is backwards)
table, mdvar = _sort_table(table, mdvar)
Expand Down
3 changes: 1 addition & 2 deletions gneiss/plot/_radial.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def radialplot(tree, node_color='node_color', node_size='node_size',
--------
bifurcate
"""
# TODO: Add in example doc string

warnings.warn("This visualization are deprecated.", DeprecationWarning)
# This entire function was motivated by
# http://chuckpr.github.io/blog/trees2.html
t = UnrootedDendrogram.from_tree(tree.copy())
Expand Down
26 changes: 18 additions & 8 deletions gneiss/plot/_regression_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
from gneiss.regression._ols import OLSModel
from gneiss.regression._mixedlm import LMEModel

from bokeh.embed import file_html
from bokeh.resources import CDN
from bokeh.plotting import figure, ColumnDataSource
from bokeh.layouts import row, column
from bokeh.models import (HoverTool, BoxZoomTool, WheelZoomTool,
ResetTool, SaveTool, PanTool,
FuncTickFormatter, FixedTicker)
from bokeh.palettes import RdYlBu11 as palette
from statsmodels.sandbox.stats.multicomp import multipletests
try:
from bokeh.embed import file_html
from bokeh.resources import CDN
from bokeh.plotting import figure, ColumnDataSource
from bokeh.layouts import row, column
from bokeh.models import (HoverTool, BoxZoomTool, WheelZoomTool,
ResetTool, SaveTool, PanTool,
FuncTickFormatter, FixedTicker)
from bokeh.palettes import RdYlBu11 as palette
except:
warnings.warn("Bokeh isn't installed - the interactive visualizations won't work.")


def _projected_prediction(model, plot_width=400, plot_height=400):
Expand All @@ -41,6 +44,7 @@ def _projected_prediction(model, plot_width=400, plot_height=400):
-------
bokeh plot
"""
warnings.warn("This visualization are deprecated.", DeprecationWarning)
hover = HoverTool(tooltips=[("#SampleID", "@index")])
pred = model.predict()
pcvar = model.percent_explained()
Expand Down Expand Up @@ -82,6 +86,7 @@ def _projected_residuals(model, plot_width=400, plot_height=400):
-------
bokeh plot
"""
warnings.warn("This visualization are deprecated.", DeprecationWarning)
hover = HoverTool(tooltips=[("#SampleID", "@index")])
pcvar = model.percent_explained()
resid = model.residuals()
Expand Down Expand Up @@ -121,6 +126,8 @@ def _heatmap_summary(pvals, coefs, plot_width=1200, plot_height=400):
bokeh.charts.Heatmap
Heatmap summarizing the regression statistics.
"""
warnings.warn("This visualization are deprecated.", DeprecationWarning)

c = coefs.reset_index()
c = c.rename(columns={'index': 'balance'})

Expand Down Expand Up @@ -228,6 +235,7 @@ def _decorate_tree(t, series):

def _deposit_results(model, output_dir):
""" Store all of the core regression results into a folder. """
warnings.warn("This visualization are deprecated.", DeprecationWarning)
coefficients = model.coefficients()
coefficients.T.to_csv(os.path.join(output_dir, 'coefficients.csv'),
header=True, index=True)
Expand Down Expand Up @@ -270,6 +278,7 @@ def ols_summary(output_dir: str, model: OLSModel,
Tree object that defines the partitions of the features. Each of the
leaves correspond to the balances in the model.
"""
warnings.warn("This visualization are deprecated.", DeprecationWarning)
# Cross validation
w, h = 500, 300 # plot width and height

Expand Down Expand Up @@ -340,6 +349,7 @@ def lme_summary(output_dir: str, model: LMEModel, tree: TreeNode) -> None:
Tree object that defines the partitions of the features. Each of the
leaves correspond to the balances in the model.
"""
warnings.warn("This visualization are deprecated.", DeprecationWarning)
# log likelihood
loglike = pd.Series({r.model.endog_names: r.model.loglike(r.params)
for r in model.results})
Expand Down
6 changes: 6 additions & 0 deletions gneiss/plot/tests/test_decompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def setUp(self):
index=["a", "b", "c", "d"]
)

@unittest.skip('Visualizations are deprecated')
def test_basic_boxplot(self):
a = balance_boxplot('y', y='group', data=self.df)
res = np.vstack([i._xy for i in a.get_lines()])
Expand All @@ -56,6 +57,7 @@ def test_basic_boxplot(self):
[1.8, 1.4]])
npt.assert_allclose(res, exp)

@unittest.skip('Visualizations are deprecated')
def test_basic_hue_boxplot(self):
a = balance_boxplot('y', y='group', hue='hue', data=self.df)
res = np.vstack([i._xy for i in a.get_lines()])
Expand Down Expand Up @@ -101,6 +103,7 @@ def test_basic_hue_boxplot(self):
[1.8, 1.396]])
npt.assert_allclose(res, exp)

@unittest.skip('Visualizations are deprecated')
def test_basic_barplot(self):
ax_denom, ax_num = balance_barplots(self.tree, 'y', header='food',
feature_metadata=self.feature_df)
Expand Down Expand Up @@ -128,6 +131,7 @@ def setUp(self):
'dry': [1, 2, 3, 4, 5, 6]
}, index=['S1', 'S2', 'S3', 'S4', 'S5', 'S6'])

@unittest.skip('Visualizations are deprecated')
def test_proportion_plot(self):
np.random.seed(0)
num_features = ['A', 'B']
Expand All @@ -151,6 +155,7 @@ def test_proportion_plot(self):
exp = ['p__bar', 'p__bar', 'p__tar', 'p__far']
self.assertListEqual(res, exp)

@unittest.skip('Visualizations are deprecated')
def test_proportion_plot_order(self):
self.maxDiff = None
np.random.seed(0)
Expand All @@ -176,6 +181,7 @@ def test_proportion_plot_order(self):
exp = ['p__bar', 'p__bar', 'p__far', 'p__tar']
self.assertListEqual(res, exp)

@unittest.skip('Visualizations are deprecated')
def test_proportion_plot_order_figure(self):
self.maxDiff = None
np.random.seed(0)
Expand Down
4 changes: 2 additions & 2 deletions gneiss/plot/tests/test_heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_sort_table(self):
pdt.assert_index_equal(pd.Index(['s1', 's3', 's5', 's2', 's4']),
res_table.columns)

@unittest.skip()
@unittest.skip('Visualizations are deprecated')
def test_basic(self):
fig = heatmap(self.table, self.t, self.md,
figsize=(5, self.table.shape[0]))
Expand Down Expand Up @@ -116,7 +116,7 @@ def test_basic_line_width(self):
widths = [L.get_lw() for L in lines]
np.allclose(widths, [1.0] * len(widths))

@unittest.skip()
@unittest.skip('Visualizations are deprecated')
def test_highlights(self):

table = pd.DataFrame(block_diagonal(ncols=5, nrows=5, nblocks=2),
Expand Down
1 change: 1 addition & 0 deletions gneiss/plot/tests/test_radial.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def setUp(self):
columns=['x', 'y', 'child0', 'child1', 'is_tip'],
index=['0', '1', '2', 'y3', 'y4'])

@unittest.skip('Visualizations are deprecated')
def test_basic_plot(self):
self.maxDiff = None
exp_edges = {'dest_node': ['0', '1', '2', 'y3'],
Expand Down
3 changes: 2 additions & 1 deletion gneiss/plot/tests/test_regression_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def setUp(self):
def tearDown(self):
shutil.rmtree(self.results)

@unittest.skip('Visualizations are deprecated')
def test_visualization(self):
res = ols(formula="x1 + x2 + x3 + x4",
table=self.y, metadata=self.x)
Expand Down Expand Up @@ -130,7 +131,7 @@ def setUp(self):
def tearDown(self):
shutil.rmtree(self.results)

@unittest.skip()
@unittest.skip('Visualizations are deprecated')
def test_visualization(self):
model = mixedlm("x1 + x2", self.table, self.metadata,
groups="groups")
Expand Down

0 comments on commit c619b1b

Please sign in to comment.