raymondlouie / MiniMarS

4 stars 2 forks source link

Error in plotMarkers() for dataset 4 #24

Open anglixue opened 1 year ago

anglixue commented 1 year ago

Hi, There is one error and two warnings when running the pipeline for dataset 4

error 1: when plotting the markers, there is an error

> plotMarkers(list_markers)
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  : 
  arguments imply differing number of rows: 15, 11

This is because geneBasis method only gave 11 markers although we set it to 15. This has been warned in the previous step

warning 1:

Warning messages:
1: In geneBasisWrapper(sce, clusters, num_markers) : 
 Number of markers from geneBasis is less than the number of input markers. Reducing number of markers. 

warning 2:

2: In findClusterMarkers(final_out$training_matrix, final_out$training_clusters,  :
  No method or invalid method selected. Using all methods.

This warning shouldn't be here because we already set the method="all". However, because the code check the intersection between the input methods and the four methods, it didn't go through.'

    all_methods = c("citeFuse","sc2marker","geneBasis","xgBoost")
    method = intersect(method,all_methods)

    # Recognize the input methods
    if (length(method) == 0) {
        warning("No method or invalid method selected. Using all methods.\n")
        method = all_methods
    }

This can be easily fixed. I've amended the code in the Dev branch.

raymondlouie commented 1 year ago

Thanks!

anglixue commented 1 year ago

I found the error 1 is still not fixed. When the length of markers are different among methods, this error will occur because the melt() function expects all the lists to have the same length in order to create a rectangular data frame.

Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  : 
  arguments imply differing number of rows: 10, 9

One solution is to add NA to the shorter component

max_len <- max(lengths(list_markers))
list_markers_full <- lapply(list_markers, `length<-`, max_len)

After this, the plotMarkers() won't have such error.

anglixue commented 1 year ago

There are some other minor bugs For example,

  1. In plotPerformance function The line axis.text.x = element_text(angle=45,hjust=1,text_size), haven't been updated to axis.text.x = element_text(angle=45,hjust=1,size=text_size), So this error still pops out sometimes

    Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  : 
    polygon edge not found

We can also directly add the flag of text_size in the readme so users will know how to adjust the text size.

  1. The cluster name is not ordered randomly if we use dataset 4. It's better to have some customized functions to automatically check the order

I can update these later after today's meeting