biocore / DEICODE

Robust Aitchison PCA from sparse count data
Other
33 stars 17 forks source link

Biplot arrows not completely centered #26

Closed mortonjt closed 5 years ago

mortonjt commented 5 years ago

When visualizing in emperor - it looks like the output is not column centered (see below)

image

The fix to this would be to column center the feature vectors in the Ordination results -- it probably would look something like this

samples  = pd.DataFrame( ... )
samples = samples - samples.mean(axis=0)
features = pd.Dataframe( ... )
features = features - features.mean(axis=0)
res = OrdinationResults(samples=samples, features=features, ...)

The results are already row centered (bc of the clr transform), but column centering still needs to happen for proper visualization in emperor, especially for the biplot arrows.

The previous result is not wrong per say, but having all of the inputs centered would make these ordinations more consistent with the traditional PCA literature.

Can push in a PR if necessary.

cameronmartino commented 5 years ago

@mortonjt This is a good point and nice catch, I will put in a PR now for this. Thanks!