Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error saving in resultDir #49

Open
kimleed opened this issue Sep 17, 2023 · 1 comment
Open

Error saving in resultDir #49

kimleed opened this issue Sep 17, 2023 · 1 comment

Comments

@kimleed
Copy link

kimleed commented Sep 17, 2023

Analysis DONE, saving the results...
Error in if (!dir.exists(rawFCSdir)) { : the condition has length > 1

I keep getting the above error message.

Any tips on troubleshooting?

Using R 4.3.1 on Mac and Bioconductor 3.17

@Diffeyb
Copy link

Diffeyb commented Aug 30, 2024

Hi,

I came across this a while back and found the problem/solution. It's due to this section in the main function:

cytofkit2/R/cytofkit.R

Lines 136 to 148 in 173744d

if (is.null(fcsFiles) || is.na(fcsFiles) || is.nan(fcsFiles)){
stop("Wrong input fcsFiles!")
}else if (length(fcsFiles) == 1 && file.info(fcsFiles)$isdir) {
fcsFiles <- list.files(path = fcsFiles, pattern = ".fcs$",
full.names = TRUE)
rawFCSdir <- dirname(fcsFiles)
}else{
if(dirname(fcsFiles[1]) == "."){
rawFCSdir <- getwd()
}else{
rawFCSdir <- dirname(fcsFiles[1])
}
}

Specifically lines 138:141. You're supplying a path to your FCS files, so it updates 'fcsFiles' to a path list of fcs files in that folder, but then doesn't take that into account when setting the rawFCSdir and assigns it the dir of every FCS file. That's what causes the condition has length>1 error, rawFCSdir is as long as the number of files you have.

There are two solutions, either move the definition of rawFCSdir above the file discovery and drop the dirname() as it's already the directory :
rawFCSdir <- fcsFiles
fcsFiles <- list.files(path = fcsFiles, pattern = ".fcs$",
full.names = TRUE)
Or my preference (as it's simpler), only take the first directory from the list:
fcsFiles <- list.files(path = fcsFiles, pattern = ".fcs$",
full.names = TRUE)
rawFCSdir <- dirname(fcsFiles)[1]
That way you only have the one raw directory and nothing breaks.

As for how to update it. I've no idea if this is a common practice or not, but something I stumbled across is trace(). Put your function in and set edit=TRUE and it'll pop a window to edit the function in your session, so for this you'd have:
'trace(cytofkit2::cytofkit,edit=TRUE)'
Then save it and it'll update the function when it until you end the session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants