Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datashader min_alpha not in Holoviews #2108

Closed
Mossi8 opened this issue Nov 9, 2017 · 4 comments
Closed

Datashader min_alpha not in Holoviews #2108

Mossi8 opened this issue Nov 9, 2017 · 4 comments
Labels
type: feature A major new feature

Comments

@Mossi8
Copy link

Mossi8 commented Nov 9, 2017

Hi, I am new both at Holoviews and Datashader. But I tried to get the same plot that I get using datashader using Holoviews but it is being impossible because the datashade function does not have this min_alpha parameter that is present if I only use datashader function tf.shade.

It is important, since as I zoom in I get only a few bins really intense which mask almost the rest of the image.

Thank you

Code in datashader (part of if):
background = "black"
export = partial(export_image, export_path="export", background=background)
cm = partial(colormap_select, reverse=(background=="black"))

def create_image(x_range, y_range, w=plot_width, h=plot_height):
cvs = ds.Canvas(plot_width=w, plot_height=h, x_range=x_range, y_range=y_range)
agg = cvs.points(data, 'X_coordinate', 'Y_coordinate', ds.count_cat("Gene"))
img = tf.shade(agg, how = "eq_hist", min_alpha = 255)
spread = tf.dynspread(img, threshold = 0.1, max_px = 1, how="over")
return spread

p = base_plot(background_fill_color=background)
export(create_image(*data_smFISH_coords),"5_smFISH")
InteractiveImage(p, create_image)

Code using Holoviews ():
import numpy as np
import holoviews as hv
import datashader as ds
from holoviews.operation.datashader import aggregate, datashade, dynspread, shade

hv.notebook_extension('bokeh')
dynspread.max_px=1
dynspread.threshold=0.5
shade.cmap="#30a2da" # to match HV Bokeh default
data_smFISH = data
data_smFISH["Gene"] = data_smFISH["Gene"].astype("str")
dic_data = {i : hv.Points(data_smFISH[data_smFISH["Gene"].apply(lambda x: x == i)]
[["X_coordinate", "Y_coordinate"]]) for i in data["Gene"].unique()}
Nd = hv.NdOverlay(dic_data, kdims=["Gene"])
agg = datashade(Nd, aggregator=ds.count_cat('Gene'))
dynspread(agg, how = "over")

@philippjfr philippjfr added the type: feature A major new feature label Nov 9, 2017
@jlstevens
Copy link
Contributor

Thanks for reporting this.

We should expose as much functionality from datashader as we can so I'm assigning this issue to the next milestone. I don't expect it will take too much effort to support. @philippjfr Can you confirm that there is no easy way to set min_alpha currently?

@Mossi8
Copy link
Author

Mossi8 commented Nov 9, 2017

Yes, I have read through the datashader.py script and at some point it transforms the RGBA to RGB (as I understood), therefore, there isn't any alpha or min_alpha parameter to optimize. Which practically means that the plot is the same as the equivalent to using datashader with min_alpha = 0.

I have also tried different things, but nothing solved the problem.

Thank you for your time

@jbednar
Copy link
Member

jbednar commented Nov 9, 2017

Right; this is an omission from holoviews.operation.datashader.shade(), which was probably written before we added min_alpha to datashader. Should be trivial; I'll make a PR.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature A major new feature
Projects
None yet
Development

No branches or pull requests

4 participants