cfDNA pro
Entering edit mode
Last seen 9 weeks ago
United States

Hi , I am trying to use cfDNA pro package . I have four directories namely Blood , Urine, Blood_control and Urine_contro where my four cohorts are stored. I generated a data path object using following code

data=list.files(path = ".", pattern = "txt", all.files = FALSE,
           full.names = FALSE, recursive = TRUE)

Data path file looks like following

[1] "blood_control/Control-2.txt"
[2] "blood_control/Control-3.txt"
[3] "blood_control/Control-4.txt"
[4] "blood_control/Control-5.txt"
[5] "blood/APK-01-0027.txt"
[6] "blood/APK-01-0029.txt"

Then Created a group list


Then I used following code to generate plot as list.

result<-sapply(grp_list, function(x){
  result <-callSize(path = data) %>% 
    dplyr::filter(group==as.character(x)) %>% 
}, simplify = FALSE)

I am getting the following error. It seems that package is looking for an object called "group"

setting default outfmt to df. setting default input_type to picard. Error in dplyr::filter(): ! Problem while computing ..1 = group == as.character(x). Caused by error: ! object 'group' not found Backtrace:

  1. base::sapply(...)
  2., group == as.character(x))
    1. dplyr:::filter_rows(.data, ..., caller_env = caller_env())
    2. dplyr:::filter_eval(dots, mask = mask, error_call = error_call)
    3. mask$eval_all_filter(dots, env_filter) Error in dplyr::filter(., group == as.character(x)) : Caused by error: ! object 'group' not found ‘/tmp/Rtmp0ToHu5/downloaded_packages’
cfDNAPro • 103 views
Entering edit mode
hw538 • 0
Last seen 4 weeks ago
United Kingdom


I am Haichao, the author of cfDNAPro.

There are two issues in your code:

  • the input 'data' should be a path to the parent folder containing all of your sub-folders(i.e. blood, urine, blood_control, urine_control), for example, you sub-folders are stored in /path/to/parent/folder , then you should set data as /path/to/parent/folder
  • use lapply instead of sapply

Here is the solution to your question:

data <- "/path/to/parent/folder"

# make sure the names below match with the sub-folder name.

# write this function independently,  so as to make the code tidier. 
f <- function(x) {
  result <- callSize(path = data_path) %>% 
    dplyr::filter(group == as.character(x)) %>%

# use lapply
result<-lapply(grp_list, f)

in the result, you will find the plots for each cohort. Please don't hesitate to let me know further questions. (if any)

Best wishes, Haichao


Login before adding your answer.

Traffic: 581 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6