Plotting PCA chart using biopython

Hi,
Im trying to plot a PCA chart using biopython.
I’m new to biopython and python in general so excuse me if my code doesnt look good.
I tried to do something like that:

from Bio.Cluster import pca
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

#PCA chart
with open('heat2forpca.csv', 'r', encoding='mac_roman', newline="") as csvfile2:
    df2 = pd.read_csv(csvfile2, sep=',').fillna(0)
columnmean, coordinates, components, eigenvalues = pca(df2)
plt.plot(pca(df2))
plt.show()

but I get this error:

Traceback (most recent call last):

  File "C:UsersLenovoDesktopthird yearflowerprojectuntitled0.py", line 72, in <module>
    columnmean, coordinates, components, eigenvalues = pca(df2)

  File "C:UsersLenovoanaconda3libsite-packagesBioCluster__init__.py", line 621, in pca
    _cluster.pca(data, columnmean, coordinates, pc, eigenvalues)

RuntimeError: data is not contiguous

my dataframe looks like this:

print(df2)
     Unknown  ...  Triacontanoic acid methyl ester
0    1082585  ...                           143327
1     958408  ...                           111371
2    1067961  ...                            97396
3    1072394  ...                           111287
4     917288  ...                            79464
..       ...  ...                              ...
100   619474  ...                            99796
101   339709  ...                            88881
102   331859  ...                            74320
103   543078  ...                            67988
104   378728  ...                            57975

[105 rows x 140 columns]

any kind of help will be appreciated!

Source link