DillonHammill / CytoExploreR

Interactive Cytometry Data Analysis
60 stars 13 forks source link

Error in cyto_gatingTemplate_generate #123

Open Biomiha opened 3 years ago

Biomiha commented 3 years ago

Hi @DillonHammill,

I've tried to use the cyto_gatingTemplate_generate to export a gating template for a GatingSet imported from FlowJo using CytoML (similar use case to Issue #41 ). I get the following error:

 Error in .cpp_getGate(obj@pointer, sampleNames(obj), y) : 
   no gate associated with root node.

If I remove the root node, I lose all nodes so that's not an option. Not sure if anything has changed in how Gating Hierarchies are handled or if the issue is at my end?

Thanks.

DillonHammill commented 3 years ago

@Biomiha, can you send through the output of openCyto::gh_generate_template(gs[[1]]) so I can take a closer look? Looks like cyto_gatingTemplate_generate() is trying to extract the root node as a gate, since this is not stored as a gate, we get the error. I have tried using the function on some test data and it works as expected, I suspect that there is something different about your gating scheme which is causing the error.

Biomiha commented 3 years ago

Thanks @DillonHammill. I'll close this until I've had a chance to see what the issue is.

Biomiha commented 1 month ago

Hi @DillonHammill,

I hope all is well with you. I hope you don't mind if I reopen this issue. I have come across a new error when attempting to generate a gating template from an existing GatingSet that was generated by reading a flowjo workspace into R.

when running:

cyto_gatingTemplate_generate(x = gs, gatingTemplate = "gT.csv")

I get

Error: NA/NaN argument

and when I call .traceback() I get:

[[1]]
stop(gettextf(fmt, ..., domain = domain), domain = NA, call. = FALSE)

[[2]]
stopf(err$message)

[[3]]
.checkTypos(e, names_x)

[[4]]
value[[3L]](cond)

[[5]]
tryCatchOne(expr, names, parentenv, handlers[[1L]])

[[6]]
tryCatchList(expr, classes, parentenv, handlers)

[[7]]
tryCatch(eval(.massagei(isub), x, ienv), error = function(e) {
    if (grepl(":=.*defined for use in j.*only", e$message)) 
        stopf("Operator := detected in i, the first argument inside DT[...], but is only valid in the second argument, j. Most often, this happens when forgetting the first comma (e.g. DT[newvar := 5] instead of DT[ , new_var := 5]). Please double-check the syntax. Run traceback(), and debugger() to get a line number.")
    else .checkTypos(e, names_x)
})

[[8]]
`[.data.table`(gt_entries, 1:ind, )

[[9]]
gt_entries[1:ind, ]

[[10]]
rbind(gt_entries[1:ind, ], gt_bool_chunk[z, ], gt_entries[ind + 
    1:nrow(gt_entries), , drop = TRUE])

[[11]]
FUN(X[[i]], ...)

[[12]]
lapply(seq_len(nrow(gt_bool_chunk)), function(z) {
    gate_pops <- gt_bool_chunk$gating_args[z]
    gate_pops <- unlist(strsplit(gate_pops, "\\||\\&|\\!"))
    gate_pops <- gate_pops[!LAPPLY(gate_pops, ".empty")]
    ind <- LAPPLY(gate_pops, function(pop) {
        match(pop, gt_entries$alias)
    })
    ind <- max(ind)
    gt_entries <<- rbind(gt_entries[1:ind, ], gt_bool_chunk[z, 
        ], gt_entries[ind + 1:nrow(gt_entries), , drop = TRUE])
})

[[13]]
cyto_gatingTemplate_generate.GatingHierarchy(x[[1]], gatingTemplate = gatingTemplate, 
    ...)

[[14]]
cyto_gatingTemplate_generate(x[[1]], gatingTemplate = gatingTemplate, 
    ...)

[[15]]
cyto_gatingTemplate_generate.GatingSet(x = gs, 
    gatingTemplate = "gT.csv")

[[16]]
cyto_gatingTemplate_generate(x = gs, 
    gatingTemplate = "gT.csv")

Seems to be something to do with a call to data.table. Any idea from the traceback about what the issue could be?

Thanks ever so much!