Roestlab / massdash

MassDash: A web-based dashboard for streamlined DIA-MS visualization, analysis, prototyping, and optimization
https://massdash.streamlit.app/
BSD 3-Clause "New" or "Revised" License
16 stars 3 forks source link

Plotting Issues #34

Closed jcharkow closed 10 months ago

jcharkow commented 10 months ago

I am testing out the plotting module and running into difficulty with getting the plotting functions to work.

Here is my code

from massseer.loaders.SqMassLoader import SqMassLoader
import os
from massseer.plotting.InteractivePlotter import InteractivePlotter
from massseer.plotting.GenericPlotter import PlotConfig

pep = "NKESPT(UniMod:21)KAIVR(UniMod:267)"
charge = 3
pwd = "../tests/test_data/"
loader = SqMassLoader([os.path.join(pwd + "xics/test_chrom_1.sqMass")], os.path.join(pwd + "osw/test_data.osw"))
transitionGroup = list(loader.loadTransitionGroups(pep, charge).values())[0]

pc = PlotConfig()

plotter = InteractivePlotter(pc)

plotter.plot(transitionGroup)

I am running into several errors regarding the title and if I remove the title also getting errors later on, possibly because the methods are not in use anymore.

singjc commented 10 months ago

What errors are you getting?

I have a working instance of the plotting here path/refactor_ui.

But currently the issue I'm running into is that the transitionGroup from loadTransitionGroups only contains the precursor data and not the transition data.

singjc commented 10 months ago

I see, so if a title is not provided, it throws an error about font size, because a title is still passed to the bokeh figure , object, and since the deafult for title in plotConfig is None, it can't assign text sizing stuff to it.

I can change the way the figure object is initiated to deal with this case.

AttributeError: 'NoneType' object has no attribute 'text_font_size'
Traceback:

File "/home/justincsing/anaconda3/envs/py39/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
    exec(code, module.__dict__)
File "/media/justincsing/ExtraDrive1/Documents2/Roest_Lab/Github/MassSeer/massseer/gui.py", line 76, in <module>
    XICExperiment.main()
File "/media/justincsing/ExtraDrive1/Documents2/Roest_Lab/Github/MassSeer/massseer/sever/ExtractedIonChromatogramAnalysisServer.py", line 68, in main
    plot_obj = plotter.plot(tr_group)
File "/media/justincsing/ExtraDrive1/Documents2/Roest_Lab/Github/MassSeer/massseer/plotting/InteractivePlotter.py", line 40, in plot
    return self.plot_chromatogram(transitionGroup)
File "/media/justincsing/ExtraDrive1/Documents2/Roest_Lab/Github/MassSeer/massseer/plotting/InteractivePlotter.py", line 158, in plot_chromatogram
    p.title.text_font_size = "16pt"
singjc commented 10 months ago

What is the error when you do pass a title though? I can't reproduce any errors with that

jcharkow commented 10 months ago

image

singjc commented 10 months ago

Ahh okay, right now I attach a targeted_transition_list (pd.Dataframe) to the TransitionGroup object which contains the meta data (precursor_mz, product_mz, product_charge) for the selected precursor (peptide, charge) that you want to draw a plot for.

I have this method filter_for_target_transition_list in the SpectralLibraryLoader class, that gets a filtered transition list with information for only a specific precursor. And then I add it to the TransitionGroup here . Which may not be the best way :shrug:

I could make this optional, if it contains the meta data, include those in the hovertool, otherwise they won't be present in the hovertool. What do you think? Or if we load the meta data directly from the loadTransitionGroups method

jcharkow commented 10 months ago

I think that maybe the metadata is not needed? I am learning towards making it optional. I am sure the hovertool gets quite busy with all the metadata so it might not be needed for all purposes. Either option sounds good though

singjc commented 10 months ago

@jcharkow I made a fix #35, can you check to see if it addresses these issues