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

tss_export() fail #198

Open
perinom opened this issue Nov 3, 2021 · 2 comments
Open

tss_export() fail #198

perinom opened this issue Nov 3, 2021 · 2 comments

Comments

@perinom
Copy link

perinom commented Nov 3, 2021

Hi,

I'm trying to export the counts to a table to works around #193 but

tss_export(exp,
           samples = "all",
           file_type = "table",
           out_dir = testing_out,
           diff_tss = FALSE,
           sep = "\t")

fails with

"Error in fwrite(x, export_file, sep = sep, col.names = TRUE, row.names = FALSE, : is.list(x) is not TRUE
8.
stop(simpleError(msg, call = if (p <- sys.parent(1L)) sys.call(p)))
7.
stopifnot(is.list(x), identical(quote, "auto") || isTRUEorFALSE(quote), is.character(sep) && length(sep) == 1L && nchar(sep) == 1L, is.character(sep2) && length(sep2) == 3L && nchar(sep2[2L]) == 1L, is.character(dec) && length(dec) == 1L && nchar(dec) == ...
6.
fwrite(x, export_file, sep = sep, col.names = TRUE, row.names = FALSE, quote = FALSE)
5.
.f(.x[[i]], .y[[i]], ...)
4.
map2(.x, .y, .f, ...)
3.
walk2(.x, vec_index(.x), .f, ...)
2.
iwalk(export_samples, function(x, y) { export_file <- file.path(ifelse(is.na(out_dir), getwd(), out_dir), str_c(y, "_TSSs.tsv")) fwrite(x, export_file, sep = sep, col.names = TRUE, row.names = FALSE, ...
1.
tss_export(exp, samples = "all", file_type = "table", out_dir = testing_out, diff_tss = FALSE, sep = "\t")
"

the following (code taken from data_export.R) works, though

sample_names <- names(exp@counts$TSSs$raw)
export_samples <- exp@counts$TSSs$raw[sample_names]

## add column with sample name, remove unecessary columns
small_frames = imap(export_samples, function(sample_df, sample_name){
  sample_df %>% 
  mutate(sample_name = sample_name) %>% 
  select(sample_name, FHASH, score)
})

## Combine all observations, convert to matrix for DESeq2
count_matrix = bind_rows(small_frames) %>% 
  pivot_wider(names_from = sample_name, values_from = score) %>% 
  column_to_rownames(., var = "FHASH") %>% 
  as.matrix()

#convert NA to zero
count_matrix[is.na(count_matrix)] <- 0
@gzentner
Copy link
Collaborator

gzentner commented Nov 8, 2021

I get this error when attempting to export bedgraphs:

> tss_export(exp)
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'i' in selecting a method for function '[': could not find function "strand"

However, it's fixed by loading the plyranges package. Does that do anything for your error?

@perinom
Copy link
Author

perinom commented Nov 11, 2021

Hi,
thanks for looking into it!

I can reproduce your behaviour for bedgraphs but plyranges doesn't help for exporting to table

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