Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions docs/source/user_guide/interactive_plots.rst
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blacken-docs] reported by reviewdog 🐶

raster = (
hd.rasterize(
points,
cmap=process_cmap("blues", provider="bokeh"),
aggregator=ds.sum("inty"),
cnorm="log",
alpha=10,
min_alpha=0,
)
.opts(active_tools=["box_zoom"], tools=["hover"], hooks=[new_bounds_hook])
)

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ interactively zoomed-in if you execute the code in a notebook
import holoviews.operation.datashader as hd
from holoviews.plotting.util import process_cmap
from holoviews import opts, dim
import sys

hv.extension("bokeh")

Expand All @@ -29,13 +28,20 @@ interactively zoomed-in if you execute the code in a notebook
loadopts.setMSLevels([1])
loadopts.setSkipXMLChecks(True)
loadopts.setIntensity32Bit(True)
loadopts.setIntensityRange(oms.DRange1(oms.DPosition1(5000), oms.DPosition1(sys.maxsize)))
loader.setOptions(loadopts)
loader.load("../../../src/data/BSA1.mzML", exp)

# Filter out low-intensity peaks using ThresholdMower
threshold_filter = oms.ThresholdMower()
params = threshold_filter.getDefaults()
params.setValue(b"threshold", 5000.0)
threshold_filter.setParameters(params)
threshold_filter.filterPeakMap(exp)

exp.updateRanges()
expandcols = ["RT", "mz", "inty"]
spectraarrs2d = exp.get2DPeakDataLong(
exp.getMinRT(), exp.getMaxRT(), exp.getMinMZ(), exp.getMaxMZ()
exp.getMinRT(), exp.getMaxRT(), exp.getMinMZ(), exp.getMaxMZ(), 1
)
spectradf = pd.DataFrame(dict(zip(expandcols, spectraarrs2d)))
spectradf = spectradf.set_index(["RT", "mz"])
Expand Down Expand Up @@ -75,17 +81,14 @@ interactively zoomed-in if you execute the code in a notebook
min_alpha=0,
)
.opts(active_tools=["box_zoom"], tools=["hover"], hooks=[new_bounds_hook])
.opts( # weird.. I have no idea why one has to do this. But with one opts you will get an error
plot=dict(
width=800,
height=800,
xlabel="Retention time (s)",
ylabel="mass/charge (Da)",
)
)
)

hd.dynspread(raster, threshold=0.7, how="add", shape="square")
hd.dynspread(raster, threshold=0.7, how="add", shape="square").opts(
width=800,
height=800,
xlabel="Retention time (s)",
ylabel="mass/charge (Da)",
)


Result:
Expand Down