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

Support OMERO.table StringColumn #47

Open
will-moore opened this issue Aug 15, 2018 · 9 comments
Open

Support OMERO.table StringColumn #47

will-moore opened this issue Aug 15, 2018 · 9 comments

Comments

@will-moore
Copy link
Member

will-moore commented Aug 15, 2018

From https://www.openmicroscopy.org/qa2/qa/feedback/21658/ and https://www.openmicroscopy.org/qa2/qa/feedback/21733/

If a user has an OMERO.table with StringColumns they get listed in the "Add Table data..." menu but when chosen, the loading of data fails because histogram can't be created (error below).

Seems that when loading filters (includes ALL columns from a table) we only try to get numpy min/max/histogram for DoubleColumn and LongColumn (https://github.com/ome/omero-parade/blob/master/omero_parade/table_filters/omero_filters.py#L74)

However, for loading Table data, we don't test column type, so numpy.histogram, numpy.amin, numpy.amax are tried for e.g. StringColumn which fails.
If I comment-out these lines in views.py get_data() then it returns just the values dict which is displayed in the OMERO.parade table OK.
Not sure why we need to calculate histogram, min and max since they're not used by the UI in any way?

For StringColumns that actually contain Long/Float values, I wrote a script to convert columns to LongColumn or DoubleColumn in a new Table:
https://gitlab.com/openmicroscopy/incubator/python-scripts/blob/master/omero_table_stringcol_to_doublecol.py
but this doesn't help if the values are actually Strings.

File "/home/omero_user/omeroenv2/local/lib/python2.7/site-packages/omero_parade/views.py", line 177, in get_data
histogram, bin_edges = numpy.histogram(values, bins=bins)
File "/home/omero_user/omeroenv2/local/lib/python2.7/site-packages/numpy/lib/histograms.py", line 676, in histogram
bin_edges, uniform_bins = _get_bin_edges(a, bins, range, weights)
File "/home/omero_user/omeroenv2/local/lib/python2.7/site-packages/numpy/lib/histograms.py", line 299, in _get_bin_edges
first_edge, last_edge = _get_outer_edges(a, range)
File "/home/omero_user/omeroenv2/local/lib/python2.7/site-packages/numpy/lib/histograms.py", line 250, in _get_outer_edges
first_edge, last_edge = a.min(), a.max()
File "/home/omero_user/omeroenv2/local/lib/python2.7/site-packages/numpy/core/_methods.py", line 32, in _amin
return umr_minimum(a, axis, None, out, keepdims, initial)
TypeError: cannot perform reduce with flexible type
path:/parade/data/VGFibGVfU3BvdCBDZWxsIENvdW50/,
@will-moore will-moore changed the title Data provider Table histogram Support OMERO.table StringColumn Aug 20, 2018
@dsudar
Copy link

dsudar commented Aug 20, 2018

Thanks @will-moore . I will try the script but already noticed that for my situation I'll have to make a few mods so it can handle tables that are attached at the Screen (not Plate) level.

The script will indeed serve as a patch but indeed best if the parade functionality can handle StringColumns "natively" since that is what "omero metadata populate" generates, right?
Side note: I just noticed on PyPI that there is a omero-metadata CLI plugin version 0.2.2. Should I start using that instead of the older built-in version that is enabled with OMERO_DEV_PLUGINS? Does that new version perchance create DoubleColumn, maybe? If not, maybe it should?

@will-moore
Copy link
Member Author

Hi Damir,
To update for a Screen, just replace Plate with Screen on these lines

link = omero.model.PlateAnnotationLinkI()
link.setParent(omero.model.PlateI(plate_id, False))

Yes, please use the latest omero-metadata plugin.
Looking at the source code https://github.com/ome/omero-metadata/blob/master/src/populate_metadata.py#L76 it seems to support creation of different column types with --columns but haven't worked out how to run it yet.

@will-moore
Copy link
Member Author

Hi Damir, with @joshmoore and @sbesson's help I managed to use the --columns argument. It's not supported via the CLI, so you have to run the populate_metadata.py directly...

With a sample csv that looks like:

Well, Drug, Concentration, Cell Count, Percent Mitotic
A1, DMSO, 10.1, 10, 25.4
A2, DMSO, 0.1, 1000, 2.54
A3, DMSO, 5.5, 550, 4
B1, Monastrol, 12.3, 50, 44.43
B2, Drug3, 1.1, 1, 15.4
B3, Water, 20.1, 44, 12.3
C1, Acid, 15.1, 20, 25.4
C2, DrugX, 4.44, 10, 35.4
C3, XYZ, 0.001, 303, 45.4

Columns are Well, String, Double, Long, Double well,s,d,l,d
I ran:

$ pip install omero-metadata

$ python /usr/local/lib/python2.7/site-packages/populate_metadata.py -s localhost -p 4064 -u username -w password --columns well,s,d,l,d Plate:7967 data_for_plate_7967.csv

This allowed me to load the Concentration, Cell Count, Percent Mitotic columns in OMERO.parade "Add table data..." (but not the Drug column because of the numpy histogram() fail as mentioned above).
Hope that helps.

@dsudar
Copy link

dsudar commented Aug 22, 2018 via email

@will-moore
Copy link
Member Author

Hi Damir, yes there is a "plate" argument - See https://github.com/ome/omero-metadata/blob/master/src/populate_metadata.py#L76
or

$ python /usr/local/lib/python2.7/site-packages/populate_metadata.py --help

@dsudar
Copy link

dsudar commented Sep 20, 2018 via email

@chris-allan
Copy link
Member

@dsudar: All of the functionality @emilroz demonstrated in our webinar is included in #39. If you were to merge that PR with master you would have the exact code that was used. There are several limitations and it is the focus of ongoing work.

/cc @jburel

@dsudar
Copy link

dsudar commented Sep 25, 2018

Thanks @chris-allan . I'll first try to do that on a test instance. Meanwhile, for the StringColumn issue, I have been trying the work-around where I am coping those metadata columns in my Table on which I want to filter to Key-Value pairs (using "omero metadata populate"). That works for what I need except that the match it uses in Add Filter... is a match-anything so when trying to filter on AAA, it will also pick up AAABBB. Any way to request an exact match?
Since this discussion is possibly of interest to others, should it be continued on the Forum?
Thanks, Damir

@will-moore
Copy link
Member Author

will-moore commented Mar 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants