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

Problem with the feature selection method #21

Closed
thomasnedelec opened this issue Apr 20, 2021 · 4 comments
Closed

Problem with the feature selection method #21

thomasnedelec opened this issue Apr 20, 2021 · 4 comments

Comments

@thomasnedelec
Copy link

Hi Ross,
I imported data and managed to cluster them with phenograph. It worked perfectly fine (honestly, it's a great tool !! I really enjoyed working with it during the week-end ) I am currently trying to build the FeatureSpace corresponding to the data and compute basic statistics. I have the following error when I run the following block :

samples = cells.list_samples()
feature_space_cells = feature_selection.FeatureSpace(experiment=cells)

AttributeError Traceback (most recent call last)
in
1 samples = cells.list_samples()
----> 2 feature_space_cells = feature_selection.FeatureSpace(experiment=cells)

/usr/local/lib/python3.8/dist-packages/cytopy/flow/feature_selection.py in init(self, experiment, sample_ids, logging_level, log)
150 if x.primary_id in sample_ids] or experiment.fcs_files
151 self.subject_ids = {x.primary_id: _fetch_subject(x) for x in self._fcs_files}
--> 152 self.subject_ids = {k: v.subject_id for k, v in self.subject_ids.items() if v is not None}
153 populations = [x.list_populations() for x in self._fcs_files]
154 self.populations = set([x for sl in populations for x in sl])

/usr/local/lib/python3.8/dist-packages/cytopy/flow/feature_selection.py in (.0)
150 if x.primary_id in sample_ids] or experiment.fcs_files
151 self.subject_ids = {x.primary_id: _fetch_subject(x) for x in self._fcs_files}
--> 152 self.subject_ids = {k: v.subject_id for k, v in self.subject_ids.items() if v is not None}
153 populations = [x.list_populations() for x in self._fcs_files]
154 self.populations = set([x for sl in populations for x in sl])

AttributeError: 'str' object has no attribute 'subject_id'

I have the same error whether I run
feature_space_cells = feature_selection.FeatureSpace(experiment=cells) or
feature_space_cells = feature_selection.FeatureSpace(experiment=cells, sample_ids=sample).

Is it because I imported data with csv rather than fcs ? (I used the experiment.add_dataframes method to import data).

Thanks for your help
Thomas

@burtonrj
Copy link
Owner

burtonrj commented Apr 20, 2021

Hi Thomas,

Just had a quick look at feature_selection.py and this looks like a genuine bug. _fetch_subject (line 151) does a sort of safe query on the FileGroup object and if it is associated to a Subject it returns the subject identifier. I think at some point I switched from returning the Subject object to returning the subject_id as a string and this hasn't been reflected in the code in line 152.

Surprised this bug hasn't come up before now. Serves me right for not having better test coverage! I'm working on that but as the only developer on CytoPy and a PhD student it's just a question of time I'm afraid.

I'll make this fix tonight and have an update shipped tomorrow (it's not a big job). This will come with a new docker image for you to use. If you mount that new docker image to the same drives this won't effect your notebooks/database/files.

Cheers,
Ross

burtonrj pushed a commit that referenced this issue Apr 20, 2021
@thomasnedelec
Copy link
Author

Yes, I was also thinking that you changed from returning the Subject to returning the subject_id.
No worries, it's already super helpful. Developing such clean code is impressive.
Keep me posted for the docker.
I will try to work on it tomorrow.
Best
Thomas

@burtonrj
Copy link
Owner

New docker image should be live now. Let me know if the problem persists.

@thomasnedelec
Copy link
Author

It works fine !! Cheers !

burtonrj pushed a commit that referenced this issue Aug 21, 2021
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

2 participants