chemosim-lab / ProLIF

Interaction Fingerprints for protein-ligand complexes and more
https://prolif.readthedocs.io
Apache License 2.0
361 stars 68 forks source link

how can i filter the results of fp #184

Closed hima111997 closed 7 months ago

hima111997 commented 8 months ago

image

how can i filter the results of interactions based on their proportion to enhance the plot?

cbouy commented 7 months ago

Hi,

You can directly filter the pandas DataFrame output by fp.to_dataframe and input that to the Barcode class (which is run under the hood when calling fp.plot_barcode).

Here's an example:

from prolif.plotting.barcode import Barcode

# example: filter interaction that occur in less than 30% of frames
threshold = 0.3
df = fp.to_dataframe()
# only keep interactions occurring more frequently than the threshold
above_threshold_mask = df.mean() > threshold
df_filtered = df.loc[:, above_threshold_mask]
# plot
Barcode(df_filtered).display()

Feel free to reopen the issue if you have another related question