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

Compartment names should be parameterizable #110

Closed
shntnu opened this issue Dec 7, 2020 · 7 comments
Closed

Compartment names should be parameterizable #110

shntnu opened this issue Dec 7, 2020 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@shntnu
Copy link
Member

shntnu commented Dec 7, 2020

It's possible this is already the case, but @pamzgt wasn't able to find it

@gwaybio
Copy link
Member

gwaybio commented Dec 7, 2020

the default is ["cells", "cytoplasm", and "nuclei"], but compartments are indeed parameterizable:

compartments=["cells", "cytoplasm", "nuclei"],

It is possible they are not parameterized somewhere, but if so, we should rectify.

@gwaybio
Copy link
Member

gwaybio commented Dec 7, 2020

ah, I just realized that pycytominer will throw an error for non-canonical compartments:

def check_compartments(compartments):

We should probably update this to throw a warning instead.

@pamzgt
Copy link

pamzgt commented Dec 8, 2020

My bad. I was taking a very quick look and did not realize that compartments referred to the table names in the sqlite file.

@pamzgt
Copy link

pamzgt commented Dec 8, 2020

To give a bit of context, I was trying to feed an sqlite db with the following tables: 'Per_Image', 'Per_Cells', 'Per_Cytoplasm', 'Per_Nuclei'.

passing compartments =["Per_Cells", "Per_Cytoplasm", "Per_Nuclei"] results in an error: compartment not supported, use one of ['cells', 'cytoplasm', 'nuclei']. Also, the image table should be called 'Image' and can not be parameterized.

At that moment, I did not know about cytominer-database. But I guess that it was created to fix these issues. We tested it and it worked :)

@shntnu
Copy link
Member Author

shntnu commented Dec 9, 2020

@pamzgt cytominer-database will use the same as your CSV files for the corresponding tables. So if your CSV files are called Per_Cells.csv, the table will be called Per_cells (if you use the latest version, because of this line).

But the fix is simple!

sqlite3 backend.sqlite 'alter table Per_cells rename to Cells'

See https://sqlite.org/lang_altertable.html

@gwaybio gwaybio added bug Something isn't working good first issue Good for newcomers labels Dec 14, 2020
@gwaybio gwaybio self-assigned this Dec 15, 2020
@gwaybio
Copy link
Member

gwaybio commented Dec 15, 2020

update: I needed to solve this in #111 - working on it now

@gwaybio
Copy link
Member

gwaybio commented Dec 15, 2020

turns out that the "good first issue" tag here was wrong 😂

Long story short, this is now fully modular (and fully tested) in #111

One key block preventing an easy fix is here

This is now implemented:

from pycytominer.cyto_utils.cells import SingleCells

# Only SQLite supported currently
sc = SingleCells(file_or_conn="sqlite:///EXAMPLE_PATH.sqlite")

# Merge single cell data using the appropriate linking columns
# Linking columns can also be specified for modular compartments
# Different normalization methods also available (see normalize.py)
sc_df = sc.merge_single_cells(single_cell_normalize=False)

# For the default linking cols and for specific modular formatting, run the following
from pycytominer.cyto_utils import get_default_linking_cols
get_default_linking_cols()

# Aggregate single cells
level_3_df = sc.aggregate_profiles()

# Note that above is a faster implementation of the following operation:
from pycytominer import aggregate
level_3_df = aggregate(sc_df)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants