MomX / Momocs

:dove: Morphometrics using R
http://momx.github.io/Momocs/
51 stars 19 forks source link

PCA unused argument (x) #219

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello, I am working with Package 'Momocs' to plot PCA. I get this error: Error in layer_morphospace_PCA(., x, position = c("range"), nb = 12, nr = 6, : unused argument (x)

`#PCA pca_<-PCA(eOTO)

plotPCA(pca, ~Station, zoom =0.9, chull = F, eigen = F, morphospace_positions = F, axesnames = F, axesvar = F, points = F) %>% layer_morphospace_PCA(x, position = c("range"), nb = 12, nr = 6, nc = 5, rotate = 0, size = 1, col = "#999999", flipx = FALSE, flipy = FALSE, draw = TRUE)%>% layer_ellipses( conf = 0.9, lwd = 1, alpha = 0)%>% layer_axes(lwd = 1)%>% layer_axesvar(cex=1.5)%>% layer_ellipsesaxes (conf = 0.5,lwd=1.5)%>% layer_grid( col = "#999999", lty = 3, grid = 3)%>% layer_stars(alpha = 0.8)%>% layer_points( cex=1.3) %>%

layer_eigen( nb_max =5, cex = 1 )%>%

layer_legend( cex = 1)%>% layer_title(title = "a)", cex =1)`

I have replaced morphospace to morphospace_positions and layer_morphospace to layer_morphospace_PCA following the manual of Momocs Version: 1.3.2. NB. These codes work perfectly with older Version (e.g. 1.2.9) of Momocs. Though I revised my codes according to the latest version of this pancake. Thanks for the help. Best regards,

vbonhomme commented 3 years ago

Side remark: Email or github, pick your prefzrence but please dont cross post me !

Have you tried plot(0) before your call ?

Le sam. 10 juil. 2021 12:24, Umar KHAN @.***> a écrit :

Hello, I am working with Package 'Momocs' to plot PCA. I get this error: Error in layer_morphospace_PCA(., x, position = c("range"), nb = 12, nr = 6, : unused argument (x)

`#PCA pca_<-PCA(eOTO)

plotPCA(pca, ~Station, zoom =0.9, chull = F, eigen = F, morphospace_positions = F, axesnames = F, axesvar = F, points = F) %>% layer_morphospace_PCA(x, position = c("range"), nb = 12, nr = 6, nc = 5, rotate = 0, size = 1, col = "#999999", flipx = FALSE, flipy = FALSE, draw = TRUE)%>% layer_ellipses( conf = 0.9, lwd = 1, alpha = 0)%>% layer_axes(lwd = 1)%>% layer_axesvar(cex=1.5)%>% layer_ellipsesaxes (conf = 0.5,lwd=1.5)%>% layer_grid( col = "#999999", lty = 3, grid = 3)%>% layer_stars(alpha = 0.8)%>% layer_points( cex=1.3) %>%

layer_eigen( nb_max =5, cex = 1 )%>%

layer_legend( cex = 1)%>% layer_title(title = "a)", cex =1)`

I have replaced morphospace to morphospace_positions and layer_morphospace to layer_morphospace_PCA following the manual of Momocs Version: 1.3.2. NB. These codes work perfectly with older Version (e.g. 1.2.9) of Momocs. Though I revised my codes according to the latest version of this pancake. Thanks for the help. Best regards,

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MomX/Momocs/issues/219, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABECQFQSHKAOLIPUELRKEULTXANUVANCNFSM5AEDFOUQ .

ghost commented 3 years ago

Noted with thanks. Do I need to write this "plot(0)" at the end of script? I did and nothing appeared except square chart with a dot.
`> pca_<-PCA(eOTO)

plotPCA(pca, ~Station, zoom =0.9, chull = F, eigen = F, morphospace_positions = F, axesnames = F, axesvar = F, points = F) %>%

  • layer_morphospace_PCA(x, position = c("range"), nb = 12, nr = 6, nc = 5, rotate = 0,
  • size = 1, col = "#999999", flipx = FALSE, flipy = FALSE,
  • draw = TRUE)%>%
  • layer_ellipses( conf = 0.9, lwd = 1, alpha = 0)%>%
  • layer_axes(lwd = 1)%>%
  • layer_axesvar(cex=1.5)%>%
  • layer_ellipsesaxes (conf = 0.5,lwd=1.5)%>%
  • layer_grid( col = "#999999", lty = 3, grid = 3)%>%
  • layer_stars(alpha = 0.8)%>%
  • layer_points( cex=1.3) %>%
  • layer_eigen( nb_max =5, cex = 1 )%>%

  • layer_legend( cex = 1)%>%
  • layer_title( title = "a)", cex =1) Error in layer_morphospace_PCA(., x, position = c("range"), nb = 12, nr = 6, : unused argument (x) plot(0)`
vbonhomme commented 3 years ago

plot(0) then your call to plot_PCA() does it work ?

Le sam. 10 juil. 2021 à 16:47, Umar KHAN @.***> a écrit :

Noted with thanks. Do I need to write this "plot(0)" at the end of script? I did and nothing appeared except square chart with a dot.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MomX/Momocs/issues/219#issuecomment-877649473, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABECQFSKIP27MSRRWPWFBETTXBMRJANCNFSM5AEDFOUQ .

-- vincentbonhomme.fr http://www.vincentbonhomme.fr

ghost commented 3 years ago

Dear Vincent, I get two errors which are: 1) Error in strheight(title) : plot.new has not been called yet and 2) Error in .check(any(class(x) == "PCA"), "only supported on LDA objects") : argument "x" is missing, with no default. I added these [plot(0) plot_PCA()] at the end of my codes.

vbonhomme commented 3 years ago

just add plot(0) BEFORE your lines for the graphics. sth like:

plot(1)

eOTO %>% PCA %>% plot_PCA(~Station)

Le sam. 10 juil. 2021 à 22:30, Umar KHAN @.***> a écrit :

Dear Vincent, I get two errors which are:

  1. Error in strheight(title) : plot.new has not been called yet and 2) Error in .check(any(class(x) == "PCA"), "only supported on LDA objects") : argument "x" is missing, with no default. I added these [plot(0) plot_PCA()] at the end of my codes.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MomX/Momocs/issues/219#issuecomment-877699859, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABECQFVVGSCDICWYQM6X2ZDTXCUVXANCNFSM5AEDFOUQ .

-- vincentbonhomme.fr http://www.vincentbonhomme.fr

ghost commented 3 years ago

I revised my codes like this: `plot(1)

eOTO %>% PCA %>% plot_PCA(~Station)

layer_ellipses( conf = 0.9, lwd = 1, alpha = 0)%>% layer_axes(lwd = 1)%>% layer_axesvar(cex=1.5)%>% layer_ellipsesaxes (conf = 0.5,lwd=1.5)%>% layer_grid( col = "#999999", lty = 3, grid = 3)%>% layer_stars(alpha = 0.8)%>% layer_points( cex=1.3) %>%

layer_eigen( nb_max =5, cex = 1 )%>%

layer_legend( cex = 1)%>% layer_title( title = "a)", cex =1)` And they work perfectly providing PCA plot. Thanks But could you please also explain why I get this error now: factor passed was a character, and coerced to a factor. when run eOTO %>% PCA %>% plot_PCA(~Station). And also this error: Error in is.factor(x$f) : argument "x" is missing, with no default when run the last line [layer_title( title = "a)", cex =1)]

vbonhomme commented 3 years ago

Fine

  1. Read the message, all is there.
  2. Read the message and fix your code typo with "a"

Le sam. 10 juil. 2021 23:01, Umar KHAN @.***> a écrit :

I revised my codes like this: `plot(1)

eOTO %>% PCA %>% plot_PCA(~Station)

layer_ellipses( conf = 0.9, lwd = 1, alpha = 0)%>% layer_axes(lwd = 1)%>% layer_axesvar(cex=1.5)%>% layer_ellipsesaxes (conf = 0.5,lwd=1.5)%>% layer_grid( col = "#999999", lty = 3, grid = 3)%>% layer_stars(alpha = 0.8)%>% layer_points( cex=1.3) %>%

layer_eigen( nb_max =5, cex = 1 )%>%

layer_legend( cex = 1)%>% layer_title( title = "a)", cex =1)` And they work perfectly providing PCA plot. Thanks But could you please also explain why I get this error now: factor passed was a character, and coerced to a factor. when run eOTO %>% PCA %>% plot_PCA(~Station). And also this error: Error in is.factor(x$f) : argument "x" is missing, with no default when run the last line [layer_title( title = "a)", cex =1)]

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MomX/Momocs/issues/219#issuecomment-877703758, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABECQFT27K5GKMBBJPFMJVLTXCYJVANCNFSM5AEDFOUQ .

ghost commented 3 years ago

Solved :-)

ghost commented 3 years ago

Dear Dr. Vincent, thank you for all the help. Momocs greatly contribute to the generic knowledge on fish morphometrics to delineate stocks. Surely, the MomX will be the next milestone in success. Respectfully,

vbonhomme commented 3 years ago

good to know it's solved. I have a problem with this layering approach. I'm a bit busy otherwise but I still hope to make time for MomX.

Le dim. 11 juil. 2021 à 19:44, Umar KHAN @.***> a écrit :

Dear Dr. Vincent, thank you for all the help. Momocs greatly contribute to the generic knowledge on fish morphometrics to delineate stocks. Surely, the MomX will be the next milestone in success. Respectfully,

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MomX/Momocs/issues/219#issuecomment-877837559, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABECQFVMRZELI2CYACUJD2DTXHKA3ANCNFSM5AEDFOUQ .

-- vincentbonhomme.fr http://www.vincentbonhomme.fr