Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numerical variables cannot be plotted in PCA #15

Open
Jakob37 opened this issue Sep 20, 2024 · 2 comments
Open

Numerical variables cannot be plotted in PCA #15

Jakob37 opened this issue Sep 20, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Jakob37
Copy link
Collaborator

Jakob37 commented Sep 20, 2024

Seems to be coming from this part of the code, which in my data converted:

> raw_df[["yield_vol"]]
 [1] 0.05 0.09 0.09 0.06 0.09 0.08 0.22 0.13 0.20 0.14 0.08 0.12 0.12 0.19 0.11 0.21 0.12 0.20 0.14 0.11 0.05 0.09 0.10 0.18 0.12 0.16 0.08 0.06 0.05
[30] 0.18 0.26 0.17 0.11 0.15 0.09 0.02 0.15 0.05 0.11 0.19 0.09 0.05 0.16

to

> raw_df[["yield_vol"]]
 [1] "X0.05" "X0.09" "X0.09" "X0.06" "X0.09" "X0.08" "X0.22" "X0.13" "X0.2"  "X0.14" "X0.08" "X0.12" "X0.12" "X0.19" "X0.11" "X0.21" "X0.12" "X0.2" 
[19] "X0.14" "X0.11" "X0.05" "X0.09" "X0.1"  "X0.18" "X0.12" "X0.16" "X0.08" "X0.06" "X0.05" "X0.18" "X0.26" "X0.17" "X0.11" "X0.15" "X0.09" "X0.02"
[37] "X0.15" "X0.05" "X0.11" "X0.19" "X0.09" "X0.05" "X0.16"

mutate_all(make.names) # Run make.names on all variables of the design matrix

After removing that line I get the desired PCA chart (before it will be a categorical coloring, one value per category):

reason

@Jakob37 Jakob37 added the bug Something isn't working label Sep 20, 2024
@Jakob37
Copy link
Collaborator Author

Jakob37 commented Sep 20, 2024

The consequece is that all variables (including numbers) in the design matrix are converted to valid names. I suspect this has been added to solve some other issue, do you know @manszamore ? I would rather revert it and solve that other issue some other way.

I can make a PR for fixing this.

@manszamore
Copy link
Member

Yes, I think this was added to allow for using variables (e.g. column names in the design matrix) beginning with numbers. But it's not ideal if it breaks the PCA, of course. Feel free to revert it! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants