Hi,
After I finish the PCA step, I tried to export the eigenvalues as csv file with error: Struct instance has no attribute ‘to_csv’. So how do I export these values? Below is my code. Thanks.
vds_pca = pca_target.pca(‘sa.scores’,k = 10, eigenvalues=‘global.eigen’)
vds_pca.globals.to_csv(‘eigen.tsv’, header=True, index=False, sep=’,’, encoding=‘utf-8’)
in 0.1, PCA returns a VariantDataset. You probably want to use vds.export_samples
But the samples table doesn’t contain eigenvalue information, it’s in globals.
ah, misunderstood. The globals isn’t a pandas dataframe, it’s basically a Python dict. vds_pca.globals['eigen']
will give you a Python list of eigenvalues.
Not really a list returned by vds_pca.globals[‘eigen’], it’s actually hail struct class:
Struct{u’PC8’: xxx, u’PC9’: xxx, u’PC2’: xxx, u’PC3’: xxx, …}
How do I programmingly convert to list or other standard data frame type that I can export to file? Thanks.
ah, it’s a list in 0.2. list(struct.values())
produces a Python list