Closed aarzalluz closed 6 years ago
What does your scaling
vector look like?
The error tells you that you are trying to apply a non-function, which might mean that you have one or more non-functions in the scaling
vector. Or somewhere else.
It would be helpful to know the output of scone() with run=FALSE
as well.
Sorry I forgot to include that info. I checked, and seem to have failed to define custom scaling functions correctly. Once I removed them from the scaling
vector and kept only the scone wrappers, I don't get the error anymore.
So... How would I go about that? Say I intended to include the SCnorm
method as a user defined function for testing. I tried the following, and sourced the function into the global environment:
SCNORM_FN <- function(ei){
eo <- SCnorm(ei)
return(eo)
}
Also, I assume there is no way to pass arguments to the SCnorm
function? I tried this, but guess it's not possible:
SCNORM_FN2 <- function(ei){
eo <- SCnorm(ei, Conditions = as.character(scone$bio),
useSpikes = TRUE)
return(eo)
}
I would think that both your custom functions should work, @mbcole any idea why they're not working?
First - this probably doesn't explain the error, but it looks like the current version of SCnorm
has a list output value. I think you want to return SCnorm::results(eo)
to return a matrix - this is a requirement of the scaling argument.
Other than that, I agree with @drisso that there shouldn't be anything wrong with the functions you defined in your global environment (before calling bplapply
): if you register MulticoreParam
as your BiocParallel
back end, then you should be able to find any functions or objects from the environment you called bplapply
, including the initialized scone
object stored there.
My best guess is that the scaling
argument is malformed, since the error was not
could not find function "SCNORM_FN"
but rather
attempt to apply non-function
The scaling argument should generally have the form of a named list of functions:
scaling = list(none = identity, sum = SUM_FN, scnorm = SCNORM_FN)
Can you share your scaling argument?
I defined scaling
as follows:
scaling <- list(none = identity,
sum = SUM_FN,
tmm = TMM_FN,
uq = UQ_FN,
fq = FQT_FN,
deseq = DESEQ_FN,
scnorm = SCNORM_FN)
Where SCNORM_FN
is:
SCNORM_FN <- function(ei){
eo <- SCnorm(ei)
return(eo)
}
I changed the BiocParallel
back end to MulticoreParam
intead of SerialParam
, as you suggested, and got the error you mentioned:
Error: BiocParallel errors element index: 7 first error: could not find function "SCnorm"
I then changed SCNORM_FN
to return(results (eo))
, which should output the normalized matrix only, instead of the list output. Will run that now, and see...
Ok - that's good because now SCNORM_FN
is being applied within scone
, just SCnorm
isn't recognized. Have you run library(SCnorm)
in advance of running scone(...)
?
Also - to clarify - you get the non-function error whenever you switch back to SerialParam
?
Weirdly, switching to SerialParam
does not produce the non-function error anymore... Which is strange, because having loaded SCnorm
and defined the SCNORM_FN
functions as above before, I did get the error with SerialParam
. The only difference I can think of was in the results(eo)
line to return a matrix... Sorry I cannot reproduce the error anymore. Somehow, scone()
is now working.
Thanks for your help :)
Glad you got it working! I'll close the issue for now, but please let us know if you encounter a similar bug again.
When using
scone()
inrun = TRUE
mode, I'm getting the following error:Error in scaling[[sc_params[i, 2]]](imputed[[sc_params[i, 1]]]) : attempt to apply non-function
I've researched a bit and it seems to arise from some BiocParallel error, because presumably the workers in the parallel computation are unable to access the functions in the global environment... But this is just speculation, because I had previously run
BiocParallel::register(BiocParallel::SerialParam())
, which thought would solve exactly that. I don't know how to get around the error, or what I could be missing.I'm making the following call to
scone()
, and my dataset consists in ~12K features and 1725 cells.And here's my
sessionInfo()
:Thanks,
Ángeles