ncborcherding / scRepertoire

A toolkit for single-cell immune profiling
https://www.borch.dev/uploads/screpertoire/
MIT License
306 stars 52 forks source link

Error in loadContigs with TRUST4 output #213

Closed pdrofelipe closed 1 year ago

pdrofelipe commented 1 year ago

Hello Nick,

I am trying to combine contigs from scRNA-seq data that I reconstructed using the TRUST4 pipeline. I used *_barcode_report.tsv and the command lines as follows bellow. It returns me the error that " could not find function "parseAIRR" "

directory <- c("/home/pedrosousa/newrepertoires/SRR14466428/SRR14466428_barcode_report.tsv")
contigs_combined <- loadContigs(directory, format = "trust4")

Error in parseAIRR(df) : could not find function "parseAIRR"

I also used the TRUST4 perl script to convert to 10x and used the same function, It gave me the same return. I tried with de AIRR output and also gave me the same return.

thanks for your help! :)

EDIT: the error with loadContigs with10X argument is: Error in parse10x(df) : could not find function "parse10x"

ncborcherding commented 1 year ago

Hey Pedro,

Lots of recent changes to this particular function - I'd recommend installing the most recent dev branch:

devtools::install_github("ncborcherding/scRepertoire@dev")

After restarting your R session - I'd change your code to the following - the loading function will automatically grab the ".tsv" file

directory <- c("/home/pedrosousa/newrepertoires/SRR14466428/")
loadContigs <- function(dir, 
                        format = "TRUST4")

I also used the TRUST4 perl script to convert to 10x and used the same function, It gave me the same return. I tried with de AIRR output and also gave me the same return.

Yeah I think something must have been broken with the perl script a long the way - hence the improved support for TRUST4 formats.

Let me know if the problem persists and happy to troubleshoot.

Nick

pdrofelipe commented 1 year ago

Hi Nick, thanks for your response!

Well, I installed the most recent dev branch and tried the code you suggested, now it returns me the following:

directory <- c("/home/pedrosousa/newrepertoires/SRR14466428/")
loadContigs <- loadContigs(directory, 
                          format = "TRUST4")

Error in str_split(df[[i]]$chain1, ",", simplify = TRUE)[, seq_len(6)] : 
  subscript out of bounds

Then, I tried with AIRR and 10x formats which were in the same folder. Both returned the same error message:

directory <- c("/home/pedrosousa/newrepertoires/SRR14466428/")
loadContigs <- loadContigs(directory, 
                          format = "AIRR")
Error in `[.data.frame`(df[[i]], , c("cell_id", "locus", "v_call", "d_call",  : 
  undefined columns selected

EDIT: After I sent this, I tried with another file and it worked! I think something was wrong in the file.tsv I was using.

Thank you very much for your attention, Nick! And congrats for the package!

pdrofelipe commented 1 year ago

Hi, Nick! Sorry to bother again,

now when I want to use the combineBCR function with the contigs, another error appears:

directory <- c("/home/pedrosousa/newrepertoires/SRR14466432/SRR14466432_barcode_report.tsv")
contig_list <- loadContigs(directory, format = "TRUST4")
combined_B <-combineBCR(
  contig_list,
  samples = NULL,
  ID = NULL,
  threshold = 0.85,
  removeNA = T,
  removeMulti = FALSE
)

Error in `slice_max()`:
! Problem while computing indices.
ℹ The error occurred in group 1: barcode = "AGGGGAGTTACCCGATTGGAG", chain = "IGK".
Caused by error:
! object 'reads' not found
Run `rlang::last_error()` to see where the error occurred.
> rlang::last_error()
<error/rlang_error>
Error in `slice_max()`:
! Problem while computing indices.
ℹ The error occurred in group 1: barcode = "AGGGGAGTTACCCGATTGGAG", chain = "IGK".
Caused by error:
! object 'reads' not found
---
Backtrace:
  1. scRepertoire::combineBCR(...)
 15. base::local(...)
 16. base::eval.parent(substitute(eval(quote(expr), envir)))
 17. base::eval(expr, p)
 18. base::eval(expr, p)
 19. base::eval(...)
 20. base::eval(...)
 21. reads
Run `rlang::last_trace()` to see the full context.
> rlang::last_trace()
<error/rlang_error>
Error in `slice_max()`:
! Problem while computing indices.
ℹ The error occurred in group 1: barcode = "AGGGGAGTTACCCGATTGGAG", chain = "IGK".
Caused by error:
! object 'reads' not found
---
Backtrace:
     ▆
  1. ├─scRepertoire::combineBCR(...)
  2. │ └─df[[i]] %>% group_by(barcode, chain) %>% ...
  3. ├─dplyr::slice_max(., n = 1, order_by = reads, with_ties = FALSE)
  4. ├─dplyr:::slice_max.data.frame(., n = 1, order_by = reads, with_ties = FALSE)
  5. │ ├─dplyr::slice(...)
  6. │ └─dplyr:::slice.data.frame(...)
  7. │   └─dplyr:::slice_rows(.data, ..., caller_env = caller_env(), error_call = current_env())
  8. │     └─dplyr:::slice_eval(mask, dots, error_call = error_call)
  9. │       ├─base::withCallingHandlers(...)
 10. │       └─mask$eval_all(quo(impl(!!!dots)))
 11. ├─dplyr (local) impl(...)
 12. │ └─dplyr:::...elt2(i)
 13. │   └─rlang::eval_bare(sym(paste0("..", i)), frame)
 14. ├─rlang (local) local(...)
 15. ├─base::local(...)
 16. │ └─base::eval.parent(substitute(eval(quote(expr), envir)))
 17. │   └─base::eval(expr, p)
 18. │     └─base::eval(expr, p)
 19. │       └─base::eval(...)
 20. │         └─base::eval(...)
 21. │           └─reads
 22. └─base::.handleSimpleError(...)
 23.   └─dplyr (local) h(simpleError(msg, call))
 24.     └─rlang::abort(bullets, call = error_call, parent = cnd)
ncborcherding commented 1 year ago

Hey Pedro -

Glad we got the TCR stuff figured out. I am going to open a separate issue for the combineBCR() issue you are seeing. This is actually a bug - will get into more detail when I post the issue.

Thanks, Nick

pdrofelipe commented 1 year ago

Hello there Nick,

So, now I have a different error message (I used one of the same datafiles I sent you in the email with the loadContigs() issue).

directory <- c("/home/pedrosousa/repertoires/SRR14466428/SRR14466428_barcode_report.tsv")
contig_list <- loadContigs(directory, format = "TRUST4")
Error in str_split(df[[i]]$chain1, ",", simplify = TRUE)[, seq_len(7)] : 
  subscript out of bounds