Plotting PCA chart using biopython
0
0
Entering edit mode
3.4 years ago
ran • 0

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:\Users\Lenovo\Desktop\third year\flower\project\untitled0.py", line 72, in <module>
    columnmean, coordinates, components, eigenvalues = pca(df2)

  File "C:\Users\Lenovo\anaconda3\lib\site-packages\Bio\Cluster\__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!

python matplotlib biopython • 842 views
ADD COMMENT

Login before adding your answer.

Traffic: 1744 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6