1

Importing raw counts on a script in R with these necessary packages

library(optparse) 
library(DESeq2)

Then went ahead with the steps of:

  1. obtained file names
  2. loaded a control table
  3. experimental table loaded
  4. tables merged
  5. removed extra stuff to avoid duplicates

The following error is raised when trying to import the raw counts:

Error in match.names(clabs, names(xi)) :
names do not match previous names :Calls: rbind ... eval -> eval -> eval -> rbind -> rbind -> match.names In addition: Warning message: NAs introduced by coercion

The piece of code where it fails is this:

# importing the raw counts
if (is.null(opt$raw_counts) == FALSE) {
  raw_counts_table <- read.table(counts_file, header=FALSE, sep = "\t", quote = "")
  raw_counts_table <- data.frame(raw_counts_table, 
        do.call(rbind, strsplit(as.character(raw_counts_table$V1),'_')))
  raw_counts_table$X2 <- as.numeric(as.character(raw_counts_table$X2))
  raw_counts_table <- t(raw_counts_table[,c("X2", "V2")])
  row.names(raw_counts_table) <- c("SAMPLE","RAW TOTAL")
  colnames(raw_counts_table) <- raw_counts_table[1,]
  raw_counts_table <- as.data.frame(raw_counts_table)
  raw_counts_table <- raw_counts_table[-1,]

  # Need to subtract off the total number of annotations
  raw_counts_table["ANNOTATION COUNT",] <- colSums(complete_table)
  raw_counts_table["OTHER",] <- raw_counts_table[1,] - raw_counts_table[2,]

  complete_table <- rbind(complete_table, raw_counts_table["OTHER",])
}

Seems like variable names have changed?

I had to change the actual file names (adding a prefix) on a previous step script in order to go ahead, but now as I changed the file names back to the original seems to find a mismatch between files?

I have read from other posts

Links mention the error raises when two data frames don't have the same name. How could I know where exactly is the mismatch?

Thanks!

Parfait
  • 104,375
  • 17
  • 94
  • 125
Ecg
  • 908
  • 1
  • 10
  • 28
  • Hi, it is great that you read other posts, but to make everyone else understand what you are dealing with, please try to make your example reproducible: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – heck1 Mar 13 '19 at 12:37
  • 1
    What are the colnames of `complete_table`. It would be nice if in general you could give some idea of the data you are working with. Or provide a workable alternative, if the data is sensitive. But I suspect the issue is on the last line of code, and you should compare `colnames(complete_table)` with `colnames(raw_counts_table)` – Aaron Hayman Mar 13 '19 at 13:28

0 Answers0