Skip to content

plotDensities Batch Column creation error and solution #51

@panfy909

Description

@panfy909

While running plotDensities, I continued to get an error:

"Error in rep(x = i, times = nrow(data[[type]][[i]])) :
invalid 'times' argument"

The error came from line 137:

dfs[[type]]$Batch <- unlist(lapply(batch_names,
                                         function(i) rep(x = I,
                                                         times = nrow(data[[type]][[i]]))))  

I found this was because the length of the batch_names was inconsistent with the number of input files for each 'data type' (original or normalized) as the batch_names object takes all the input names. Upon changing batch_names to names(data[[type]]) (see below), this resolved the issue because it only called for the batch_names in each 'data type'.

Working line:

dfs[[type]]$Batch <- unlist(lapply(names(data[[type]]),
                                       function(i) rep(x = I,
                                                       times = nrow(data[[type]][[i]]))))

I just wanted to share this in case others have had the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions