Topics

Computing persistence and plotting bar codes

nukpezah@...
 

Hi Dimitri
I have the following code (following your tutorials) for a protein point cloud that I wanted to compute the persistence bar codes. I am very new to persistence homology and python in general. This is the code that I have where Python is giving me an error that name points_file is not defined. My impression was that points_file is a class in Dionysus. The point cloud file 1P1A.pts resides in the directory tda_1P1A_Protein and the format is as you suggested 3 coordinates per line separated by spaces. Thanks
Sincerely
Jonathan

#!/usr/bin/env python
import  matplotlib.pyplot as plt
import dionysus as d
 
points =[p for p in points_file('/tda_1P1A_Protein/1P1A.pts')]
print("Number of Points:", len(points))
f = d.fill_rips(points, 2, 0.25)
p = d.homology_persistence(f)
dgms = d.init_diagrams(p,f)
d.plot.plot_bars(dgms[0], show = True)
plt.title('Betti 0 Persistence Barcodes')
plt.show()
d.plot.plot_bars(dgms[1], show = True)
plt.title('Betti 1 Persistence Barcodes')
plt.show()
d.plot.plot_bars(dgms[2], show = True)
plt.title('Betti 2 Persistence Barcodes')
plt.show()
 

Dmitriy Morozov
 

I think you are mixing up examples from two different versions of Dionysus. points_file() exists in Dionysus 1, but not 2. The two versions have little to do with each other.

Fortunately, it's easy to fix this. You can just use NumPy to replace points_file:

import numpy as np
points = np.loadtxt('/tda_1P1A_Protein/1P1A.pts')

Best,
Dmitriy

On Tue, Jul 24, 2018 at 5:09 PM, <nukpezah@...> wrote:
Hi Dimitri
I have the following code (following your tutorials) for a protein point cloud that I wanted to compute the persistence bar codes. I am very new to persistence homology and python in general. This is the code that I have where Python is giving me an error that name points_file is not defined. My impression was that points_file is a class in Dionysus. The point cloud file 1P1A.pts resides in the directory tda_1P1A_Protein and the format is as you suggested 3 coordinates per line separated by spaces. Thanks
Sincerely
Jonathan

#!/usr/bin/env python
import  matplotlib.pyplot as plt
import dionysus as d
 
points =[p for p in points_file('/tda_1P1A_Protein/1P1A.pts')]
print("Number of Points:", len(points))
f = d.fill_rips(points, 2, 0.25)
p = d.homology_persistence(f)
dgms = d.init_diagrams(p,f)
d.plot.plot_bars(dgms[0], show = True)
plt.title('Betti 0 Persistence Barcodes')
plt.show()
d.plot.plot_bars(dgms[1], show = True)
plt.title('Betti 1 Persistence Barcodes')
plt.show()
d.plot.plot_bars(dgms[2], show = True)
plt.title('Betti 2 Persistence Barcodes')
plt.show()
 


nukpezah@...
 

Hi Dimitry
Thaks for the quick response! I will do that. Thanks again.
Sincerely
Jonathan