Displayr / flipDimensionReduction

13 stars 6 forks source link

Warning message when using "Column Principal" in CorrespondenceAnalysis #4

Closed ditordccaa closed 4 years ago

ditordccaa commented 4 years ago

Hi there,

Thanks a lot for this awesome package. I was trying to apply CorrespondenceAnalysis to my toy dataset and I got the warning message below : Warning messages: 1: In max(cumDim[cumDim <= lstats]) : no non-missing arguments to max; returning -Inf 2: In max(cumDim[cumDim <= lstats]) : no non-missing arguments to max; returning -Inf

Also the plot is really missing. However, when I use the "Principal" normalization, everything works fine.

Thanks!!

mwmclean commented 4 years ago

Please provide a reproducible example, i.e. the data and the code you ran.

ditordccaa commented 4 years ago

Yes sure. Here is a toy example.

library(flipDimensionReduction)
x <- data.frame("X1" = c(32.30769, 35.38462, 32.30769),
                "X2" = c(52.17391, 27.53623, 20.28986),
                "X3" = c(28.23062, 33.59841, 38.17097),
                "X4" = c(17.94872, 35.04274, 47.00855),
                "X5" = c(34.92462, 32.41206, 32.66332),
                "X6" = c(45.55160, 35.58719, 18.86121),
                "X7" = c(16.86747, 41.56627, 41.56627),
                "X8" = c(15.80460, 40.51724, 43.67816),
                "X9" = c(39.16667, 46.66667, 14.16667)
                )

res.ca <- CorrespondenceAnalysis(data.matrix(x),
                                 normalization = "Row Principal", # Row principal (scaled) Symmetrical
                                 output = "Scatterplot",
                                 focus = NULL, 
                                 supplementary = NULL,
                                 row.names.to.remove = c("NET", "Total", "SUM"),
                                 column.names.to.remove = c("NET", "Total", "SUM"),
                                 mirror.horizontal = FALSE, 
                                 mirror.vertical = FALSE,
                                 color.palette = "Default colors",
                                 row.color = "#5B9BD5",
                                 col.color = "#ED7D31",
                                 bubble.size = NULL, 
                                 bubble.title = "",
                                 chart.title = "Correspondence analysis",
                                 transpose = FALSE,
                                 logos = NULL, 
                                 logo.size = 0.5,
                                 trend.lines = FALSE,
                                 show.gridlines = TRUE, 
                                 multiple.tables = NA,
                                 square = FALSE,
                                 max.row.labels.plot = 200, 
                                 max.col.labels.plot = 200,
                                 max.labels.plot = NA,
                                 dim1.plot = 1,
                                 dim2.plot = 2,
                                 title.font.size = 20, 
                                 x.title.font.size = 16,
                                 y.title.font.size = 16, 
                                 labels.font.size = 10,
                                 axis.font.size = 10,
                                 legend.font.size = 15 
                                 )
print(res.ca)

Cheers,

chschan commented 4 years ago

If you replace normalization = "Column Principal" with normalization = "Column principal" (with a lower case 'p'), you should be able to get it to run without warnings and a plot that looks like this:

image

chschan commented 4 years ago

I've pushed a commit to give an error when normalization is not recognized