Question: Merging HTseq files
0
gravatar for makwana.kd
5 months ago by
makwana.kd30
makwana.kd30 wrote:

Hi, I have been trying to merge HTseq files into one data matrix using following script. However, I am encountering following error;

directory <- "C/RNA SEQ adv cgrp/IWAT"

sampleFiles <- grep("COUNT FILES",list.files(directory),value=TRUE)

 condition <- c('237 COUNT FILES','264 COUNT FILES','267 COUNT FILES','265 COUNT FILES')


sampleTable <- data.frame(sampleName = sampleFiles,
+                           fileName = sampleFiles,
+                           condition = condition)


Error in data.frame(sampleName = sampleFiles, fileName = sampleFiles,  : 
  arguments imply differing number of rows: 0, 4

I have checked individual files and they all have same number of rows.

rna-seq R • 233 views
ADD COMMENTlink modified 5 months ago by Kevin Blighe66k • written 5 months ago by makwana.kd30

Hello, Did you get this problem solved? I also want to merge HTSeq files.

Thanks.

ADD REPLYlink written 10 weeks ago by Aynur40

akashagri19, please see my answer (below). If you want, please also provide more information about the problem that you are receiving, and try to include a fully reproducible example (of the error) so that we can better help you.

ADD REPLYlink written 10 weeks ago by Kevin Blighe66k

I used the following code on R

library(tidyverse)
counts_files_pattern = "\\.counts\\.txt$"
counts_table <-
  list.files(pattern = counts_files_pattern) %>%
  #apply an import function to the listed files
  map(function(x) { 
        print(x)
        read_table2(x,
                #rename second column in accordance with the file name
                col_names = c("ID", x))
      }
      ) %>%
  #merge all tables into one
  reduce(left_join, by = "ID") %>% 
  # clean up column names
  rename_all(gsub,
             pattern = counts_files_pattern,
             replacement = '') %>%
  #move ID column to row names
  column_to_rownames("ID")

I have my .txt file on the working directory, but I received this error message

Error: .x is empty, and no .init supplied.

Thanks.

ADD REPLYlink modified 9 weeks ago by h.mon31k • written 10 weeks ago by Aynur40

Where did you get this code from? Did you test it step by step?

ADD REPLYlink written 9 weeks ago by RamRS30k
0
gravatar for Kevin Blighe
5 months ago by
Kevin Blighe66k
Kevin Blighe66k wrote:

A tip so that you can get through this problem: check the output of each command and be 100% confident that each is producing what you expect.

In your specific example, check what sampleFiles and condition contain. The error message implies that 1 of these variables is empty.

Kevin

ADD COMMENTlink written 5 months ago by Kevin Blighe66k

I am sorry; I did not know it is considered as hijacking the discussion. I thought as it is a related question, if we get a solution it might be of help to us.

ADD REPLYlink modified 9 weeks ago • written 9 weeks ago by Aynur40

Please do not do this - you have already opened a question; bugging people on other questions and hijacking those discussions is bad behavior.

ADD REPLYlink written 9 weeks ago by RamRS30k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2168 users visited in the last hour