Merging HTseq files
1
0
Entering edit mode
2.1 years ago
makwana.kd ▴ 50

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 • 798 views
ADD COMMENT
0
Entering edit mode

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

Thanks.

ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode
2.1 years ago

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 COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1243 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

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

Powered by the version 2.3.6