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

add filter method to LinkGraph #269

Merged
merged 5 commits into from
Jul 15, 2024
Merged

add filter method to LinkGraph #269

merged 5 commits into from
Jul 15, 2024

Conversation

CunliangGeng
Copy link
Member

@CunliangGeng CunliangGeng commented Jul 12, 2024

To solve #265

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @CunliangGeng and the rest of your teammates on Graphite Graphite

@CunliangGeng CunliangGeng self-assigned this Jul 12, 2024
@CunliangGeng CunliangGeng linked an issue Jul 12, 2024 that may be closed by this pull request
1 task
@CunliangGeng CunliangGeng marked this pull request as ready for review July 12, 2024 14:04
Copy link
Contributor

@gcroci2 gcroci2 left a comment

Choose a reason for hiding this comment

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

Thanks for having added the filter, very very useful :)

I think there is a bug in the code - see the comment.

Also, note that the filter gives different results compared to when I filter on the same objects as it follows:

gcfs_selected = gcfs[:5]
bgcs_selected = [bgc for gcf in gcfs_selected for bgc in gcf.bgcs]
mfs_selected = mfs[:5]
spectra_selected = [spec for mf in mfs_selected for spec in mf.spectra]

lg_selected = LinkGraph()
for gcf in gcfs_selected:
    for spec in spectra_selected:
        if links.has_link(gcf, spec):
            lg_selected.add_link(gcf, spec, **links.get_link_data(gcf, spec))
    for mf in mfs_selected:
        if links.has_link(gcf, mf):
            lg_selected.add_link(gcf, mf, **links.get_link_data(gcf, mf))

# lg_selected has 74 links

Compared to when I do this

lg_selected = links.filter(gcfs_selected, spectra_selected)
# lg_selected has 68 links

src/nplinker/scoring/link_graph.py Show resolved Hide resolved
@CunliangGeng
Copy link
Member Author

CunliangGeng commented Jul 12, 2024

Try lg_selected = links.filter(gcfs_selected, spectra_selected + mfs_selected) which should give you 74 links. Don't forget the + mfs_selected

@gcroci2
Copy link
Contributor

gcroci2 commented Jul 15, 2024

Try lg_selected = links.filter(gcfs_selected, spectra_selected + mfs_selected) which should give you 74 links. Don't forget the + mfs_selected

Indeed it works! :D

Copy link
Member Author

CunliangGeng commented Jul 15, 2024

Merge activity

@CunliangGeng CunliangGeng merged commit 1e23e57 into dev Jul 15, 2024
3 checks passed
@CunliangGeng CunliangGeng deleted the add_LinkGraph_filter branch July 15, 2024 10:57
Copy link

sonarcloud bot commented Jul 15, 2024

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

Successfully merging this pull request may close these issues.

Select subset of the data
2 participants