Skip to content

tss_export() fail #198

Description

@perinom

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions