Practise yous e'er need to read a text file while not knowing what's the maximum number of columns it can take? Well, I exercise 🙂 Turns out read.tabular array function only looks at get-go five columns to determine the number of columns every bit ?read.table assist page says:

The number of data columns is adamant past looking at the get-go five lines of input (or the whole input if information technology has less than v lines), or from the length of col.names if information technology is specified and is longer. This could feasibly be incorrect if fill orblank.lines.skip are truthful, then specify col.names if necessary (equally in the 'Examples').

And so what's the workaround? Detect out the maximum in advance!

                            no_col <- max(count.fields(file, sep = "\t"))                            dataI <- read.table(file,sep="\t",fill up=TRUE,header = F,col.names=c("chr", "start", "end", "length",1:no_col))            

Since nosotros want to fill the blanks, we volition use make full=TRUE function and we may as well decide to name our columns numerically as col.names does here. Thus, the columns volition be named chr, start, terminate, length and ane, 2, 3 … maxColumn.

About mqm5775 https://www.biostars.org/u/2884/ Bioinformatics of sequences. Sex chromosomes. Enjoying Deoxyribonucleic acid in my computer. Slap-up ape Y chromosome evolution, specifically heterochromatin variability and analysis of male person fertility genes. Creative
 use of visualization, factor expression of multi-copy cistron families, genome assembly. Enthusiastic almost learning and applying new technologies: Pacific Biosciencies (expert feel), Oxford Nanopore, BioNano Genomics.