fallerlab / Ribo-ODDR

Ribo-seq focused Oligo Design pipeline for experiment-specific Depletion of Ribosomal RNAs
GNU General Public License v3.0
6 stars 0 forks source link

Order of 10+ samples #4

Closed Jelinek-J closed 3 years ago

Jelinek-J commented 3 years ago

If there are less than 10 samples, they are correctly ordered S1_X..., S2_X..., S3_X...... But if there are e.g. 21 samples, they are ordered as S1_X..., S10_X..., S11_X..., ...,S19_X..., S2_X..., S20_X..., S21_X..., S3_X..., S4_X..., ..., S9_X..., so the original order is lost.

Probably the easiest repair is to add enough leading zeros to all numbers have the same length. E.g. to replace

    tmp[[paste("S", as.character(i), "_", sample, "_reads_info", sep="")]] <- reads[,sample]
    tmp[[paste("S", as.character(i), "_", sample, "_rrna_per_info", sep="")]] <- rperc[,sample]

with

    tmp[[paste("S", sprintf(paste0("%0",nchar(as.character(length(samples))),"d"),i), "_", sample, "_reads_info", sep="")]] <- reads[,sample]
    tmp[[paste("S", sprintf(paste0("%0",nchar(as.character(length(samples))),"d"),i), "_", sample, "_rrna_per_info", sep="")]] <- rperc[,sample]

I.e. replace as.character(i) with sprintf(paste0("%0",nchar(as.character(length(samples))),"d"),i).

ferhatalkan commented 3 years ago

Thank you very much for noticing this. In the new release I will fix this.