how is the DNA Integrity Number (DIN) calculated in Bioanalyzer/TapeStation? For DNA/RNA quantification machines like the Bioanalyzer or TapeStation, the DNA Integrity Number (DIN) or RNA Integrity Number (RIN) numbers are quoted as a measure of the fragmentation of the material.

How is the DNA Integrity Number (DIN) calculated in Bioanalyzer/TapeStation? Is there any open-source software to parse/collate the data from the machines?
Note that DIN (DNA Integrity Number) and RIN (RNA Integrity Number) are different scores. I've had trouble in the past finding code or formulas for calculating both of these scores, which is very frustrating considering how frequently they are used in research papers and for NGS QC. The closest that I have been able to get to this are demonstrative graphs for various RIN numbers and DIN numbers, with a description of the variables that are included in the model.

The code that @719016 provided appears to attempt to calculate the RIN, not the DIN.

Just in case it's helpful, here is an extract of that code, only including lines that seem to be directly involved in calculating the actual B_RIN values. This is not runnable, because it depends on particular input files, and it's still pretty unintelligible:

myfiles&lt;-list.files()
results&lt;-myfiles[which(substr(myfiles,69,79)=="Results.csv")]
n &lt;- which(substr(myfiles,69,79)=="Results.csv")
targets &lt;- read.delim(myfiles[n[1]], sep=",",header=F,skip=14,as.is=T)
targets2&lt;- read.delim(myfiles[n[1]], sep=",",header=F,skip=0,as.is=T)
str3&lt;-paste0(substr(targets2[1,2],1,67),"_S")
chip_num&lt;-length(n)
samp_num_chip&lt;-length(grep(str3,myfiles))
samp_num&lt;-length(which(substr(myfiles,69,74)=="Sample"))
samples1&lt;- matrix(NA, ncol=chip_num, nrow=samp_num)
for(i in 1:chip_num)
{
    ##mod chip numb
    targets2&lt;- read.delim(myfiles[n[i]], sep=",",header=F,skip=0,as.is=T)
    str3&lt;-paste0(substr(targets2[1,2],1,67),"_S")
    samp_num_chip&lt;-length(grep(str3,myfiles))
    ##mod sample numb
    str1&lt;-substr(targets2[1,2],1,67)
    for(j in 1:samp_num_chip)
    {
        iii&lt;-j
        str5&lt;-paste0(str1,"_Sample",iii,".csv")
        samples1[j,i]&lt;-str5
    }
}
samples1&lt;-samples1[grep("2100",samples1)]
##RIN Calculator#######refined peakfinder####################
##read bioanalyzer data into a matrix called dta
##since the total RNA and mRNA assays run differently
##skip more lines for the total RNA assay
elec &lt;- read.delim("ba_lane.txt", sep="\t",header=T,as.is=T)
qc.mat &lt;- matrix(NA, ncol=1, nrow=nrow(elec))
dta &lt;- matrix(NA, nrow=1060, ncol=nrow(elec))
for(i in 1:nrow(elec))
{
    x &lt;- read.csv(as.character(elec[i,2]), header=F, skip=18, nrows=1060)
    dta[,i] &lt;- x[,2]
}
time&lt;- x[,1]
for(samples in 1:length(samples1))
{
    ##store max fluor in max.peaks matrix
    lad&lt;-samples
    ti1&lt;-17
    ti2&lt;-65
    p.row&lt;-length(dta[which(time==ti1):which(time==ti1+1),lad])*(ti2-ti1+1)
    peaks &lt;- matrix(NA, nrow=p.row, ncol=1)
    max.peaks &lt;- matrix(NA, nrow=length(seq(ti1,ti2,.05)), ncol=1)
    for (i in 1:length(seq(ti1,ti2,.05)))
    {
        ii&lt;-seq(ti1,ti2,.05)[i]
        x0&lt;- ii
        x0&lt;-round(x0,digits=3)
        y0&lt;- ii
        x&lt;- ii+.05
        x&lt;-round(x,digits=3)
        y&lt;- ii
        max.peaks[i]&lt;- max(dta[which(time==x0):which(time==x),lad])
    }    
    ##human or mouse
    cent&lt;-max(max.peaks)*.6
    ##flatworm
    ##cent&lt;-max(max.peaks)*.05
    ##define the middle of the segments
    max.avg&lt;-seq(ti1+.025,ti2+.025,.05)
    ##find time associated with peaks &gt; 5 fu and fill seconds matrix with them
    ##12.5% of max fu incase chip is fu
    sizes &lt;- which(max.peaks&gt;cent)
    gt35&lt;-which(max.avg[sizes]&gt;35)
    lt55&lt;-which(max.avg[sizes]&lt;55)
    tfr&lt;-which(duplicated(c(gt35,lt55))==TRUE)
    area&lt;-cbind(max.peaks[sizes-1][c(gt35,lt55)[tfr]],
                max.peaks[sizes][c(gt35,lt55)[tfr]],
                max.peaks[sizes+1][c(gt35,lt55)[tfr]])
    time2&lt;-cbind(max.avg[sizes-1][c(gt35,lt55)[tfr]],
                 max.avg[sizes][c(gt35,lt55)[tfr]],
                 max.avg[sizes+1][c(gt35,lt55)[tfr]])
    t1&lt;-time2[which(area[,1]&lt;cent),1][1]
    t2&lt;-time2[which(area[,1]&lt;cent),1][2]
    t3&lt;-time2[which(area[,3]&lt;cent),3][1]
    t4&lt;-time2[which(area[,3]&lt;cent),3][2]
    s18a&lt;-ifelse(is.na(t1,-30,round(t1,digits=1)))
    s18b&lt;-ifelse(is.na(t3,-35.05,round(t3,digits=1)))
    s28a&lt;-ifelse(is.na(t2,-30,round(t2,digits=1)))
    s28b&lt;-ifelse(is.na(t4,-30.05,round(t4,digits=1)))
    eta&lt;-which(time==s18a)
    etb&lt;-which(time==s18b)
    tea&lt;-which(time==s28a)
    teb&lt;-which(time==s28b)
    s18&lt;-sum(dta[eta:etb,lad])
    s28&lt;-sum(dta[tea:teb,lad])
    qc.mat[samples]&lt;-  (-1*exp((s28/s18)*-1)+1)*10
}


Mostly based on that last line, the RIN seems to be associated with the ratio of the 18s peak to the 28s peak.