rivetTDA / rivet-python

Python API for RIVET
BSD 3-Clause "New" or "Revised" License
6 stars 7 forks source link

Question: Homology dimension clarification #5

Closed yair-schiff closed 3 years ago

yair-schiff commented 4 years ago

Hi, I was hoping you could provide some clarification on the homology parameter that is used in methods such as rivet.betti.

As stated in "Persistent Homology for Virtual Screening", the ith Betti number corresponds to the number of i-dimensional holes

Screen Shot 2020-09-01 at 9 57 41 AM

However, from working with the API in this repository and exploring the RIVET GUI, I am not sure how the homology parameter comes into play. That is, even if I set, homology=0 for example, I seem to have access to information about 1-dimensional and 2-dimensional holes:

Screen Shot 2020-09-01 at 9 59 30 AM

Therefore, I was hoping to get a better understanding of what the homology parameter is doing, e.g. if I am working with 3D coordinates of molecules and I want to calculate L2 hilbert-distance between two molecules, what determines whether I should set homology=0, 1, 2...?

Thanks in advance for any help!

mlesnick commented 4 years ago

Hi Yaif, Perhaps regrettably, the term "Betti number" is used for two different invariants in this kind of mathematics. The first use, more common in topology and in TDA, is as in the quote you give from the preprint. The second use, which is quite common in commutative commutative algebra, is for the invariant RIVET is visualizing via colored dots (green, red, yellow) in the left panel of your screenshot. In the case of your screenshot, this is an invariant of the 0th homology module. when working with 2-parameter persistence, I generally refer to the latter invariants as "bigraded Betti numbers," and as you can see, the RIVET interface also uses this language. Please see the "mathematical preliminaries" section of the RIVET documentation for a brief explanation of this invariant. https://rivet.readthedocs.io/en/latest/preliminaries.html

In the language of commutative algebra, the former notion of Betti number (when considered at all indices) is often instead called the "Hilbert function" of the module. It is shown via greyscale shading in your screenshot.

On Tue, Sep 1, 2020 at 10:03 AM Yair Schiff notifications@github.com wrote:

Hi, I was hoping you could provide some clarification on the homology parameter that is used in methods such as rivet.betti https://github.com/rivetTDA/rivet-python/blob/7cd2d5eeffcb2913286359e9624f68899f0e5bc1/pyrivet/rivet.py#L247 .

As stated in the "Persistent Homology for Virtual Screening" https://chemrxiv.org/articles/PHoS_Persistent_Homology_for_Virtual_Screening/6969260, the ith Betti number corresponds to the number of i-dimensional holes [image: Screen Shot 2020-09-01 at 9 57 41 AM] https://user-images.githubusercontent.com/35781889/91860375-95477280-ec39-11ea-90c8-2c54b6550087.png

However, from working with the API in this repository and exploring the RIVET GUI, I am not sure how the homology parameter comes into play. That is, even if I set, homology=0 for example, I seem to have access to information about 1-dimensional and 2-dimensional holes: [image: Screen Shot 2020-09-01 at 9 59 30 AM] https://user-images.githubusercontent.com/35781889/91860625-e48da300-ec39-11ea-8256-43131bc527fa.png

Therefore, I was hoping to get a better understanding of what the homology parameter is doing, e.g. if I am working with 3D coordinates of molecules and I want to calculate L2 hilbert-distance between two molecules, what determines whether I should set homology=0, 1, 2...?

Thanks in advance for any help!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rivetTDA/rivet-python/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC72KBFVBVSFVBX66R5LA2TSDT5MTANCNFSM4QRYFCGQ .

yair-schiff commented 4 years ago

@mlesnick, thank you for the quick response and explanation.

To clarify, if I want to calculate the L2 hilbert distance as described in the preprint, then using the example from the api tour notebook, I would need to adjust it as follows:

aspirin_h0_betti = rivet.betti_file('aspirin-ZINC000000000053.sdf.txt', homology=0, x=10, y=10)
tylenol_h0_betti = rivet.betti_file('tylenol-ZINC000013550868.sdf.txt', homology=0, x=10, y=10)
aspirin_h1_betti = rivet.betti_file('aspirin-ZINC000000000053.sdf.txt', homology=1, x=10, y=10)
tylenol_h1_betti = rivet.betti_file('tylenol-ZINC000013550868.sdf.txt', homology=1, x=10, y=10)
aspirin_h2_betti = rivet.betti_file('aspirin-ZINC000000000053.sdf.txt', homology=2, x=10, y=10)
tylenol_h2_betti = rivet.betti_file('tylenol-ZINC000013550868.sdf.txt', homology=2, x=10, y=10)

# We can compute distance between these using Hilbert functions
from pyrivet import hilbert_distance
distance = 0
distance += hilbert_distance.distance(aspirin_h0_betti, tylenol_h0_betti)
distance += hilbert_distance.distance(aspirin_h1_betti, tylenol_h1_betti)
distance += hilbert_distance.distance(aspirin_h2_betti, tylenol_h2_betti)
print("Distance with Hilbert functions:",  distance)

is that correct? or am I still misunderstanding something