Multi-round Mononucleotide Example (without Reverse complement symmetry)

Gabriella Martini

2016-07-08

options(java.parameters = "-Xmx4000M")
library(SELEX)
library(SelexGLM)
library(grid)
workDir = "./cache/"
selex.config(workingDir=workDir, maxThreadNumber=4)

### LOCAL PATHS NEED TO BE RE-DEFINED TO RUN OFF OF MY COMPUTER
##################################################################
selexDir = "/Users/gabriella/Columbia/SELEX/"
rawdataDir = "/Users/gabriella/Columbia/rawdata/Mann/HM/"

# CLUSTER VERSIONS ARE COMMENTED OUT
#selexDir = "/vega/hblab/users/gdm2120/SELEX/SELEX/"
#rawdataDir = "/vega/hblab/projects/selex/rawdata/Mann/hm/"
##################################################################
saveDir = "gabriella/SelexGLMtest/MultiRoundNoSymmetry"
dir.create(file.path(selexDir, saveDir), showWarnings = FALSE, recursive = TRUE)


shapeTable = read.table(paste(selexDir, "gabriella/ShapeParamData/ShapeTableOrthogonal.txt", sep = ""), sep = "\t",
                        stringsAsFactors = FALSE)
ST = shapeTable[,c(1, 14:19)]
colnames(ST) = c("Sequence", "MGW", "ProT", "HelTA",
                 "HelTB", "RollA", "RollB")

selex.defineSample('r0',
                   paste(rawdataDir, "exp6/mplex1.0b.mplex2.0b.fastq.gz", sep = ""),
                   'm1r0',
                   0, 16, 'TGG', 'CCAGCTG')

selex.defineSample('r0',
                   paste(rawdataDir, "exp6/mplex1.0b.mplex2.0b.fastq.gz", sep = ""),
                   'm2r0',
                   0, 16, 'TGG', 'CCACGTC')



selex.defineSample('Ubx4a.R2',
                   paste(rawdataDir, "exp4/exdUbxiva.exdAntp.L.2.fastq.gz", sep = ""),
                   'HM.Ubx4a.Exd',
                   2, 16, 'TGG', 'CCAGCTG')

selex.defineSample('Ubx4a.R3',
                   paste(rawdataDir,"exp4/exdUbxiva.exdAntp.L.3.fastq.gz", sep = ""),
                   'HM.Ubx4a.Exd',
                   3, 16, 'TGG', 'CCAGCTG')




r0.train = selex.sample(seqName = 'r0', sampleName='m1r0', round = 0)
r0.test = selex.sample(seqName = 'r0', sampleName='m2r0', round = 0)
dataSample = selex.sample(seqName = 'Ubx4a.R2', sampleName = 'HM.Ubx4a.Exd', round = 2)
dataSample.R3 = selex.sample(seqName = 'Ubx4a.R3', sampleName = 'HM.Ubx4a.Exd', round = 3)
# MARKOV MODEL BUILT
kmax = selex.kmax(sample = r0.test)
# Train Markov model on Hm 16bp library Round 0 data
mm = selex.mm(sample = r0.train, order = NA, crossValidationSample =r0.test, Kmax = kmax, mmMethod = "TRANSITION")
mmscores = selex.mmSummary(sample = r0.train)
ido = which(mmscores$R==max(mmscores$R))
mm.order = mmscores$Order[ido]

libLen = as.numeric(as.character(selex.getAttributes(dataSample)$VariableRegionLength))

# For the sake of previous analysis on the Hox data used in this example, I will use kLen = 12 as my k-mer length, even though kLen identified through the information gain analysis has kLen = 13.
kLen = 12


#data.probeCounts = getProbeCounts(dataSample, markovModel = mm)
#save(data.probeCounts, file = paste(selexDir, saveDir, "/data.probeCounts.RData", sep = ""))
load(file = paste(selexDir, saveDir, "/data.probeCounts.RData", sep = ""))
#data.kmerTable = getKmerCountAffinities(dataSample, k = kLen, minCount = 100, markovModel = mm)
#save(data.kmerTable, file = paste(selexDir, saveDir, "/data.kmerTable.RData", sep = ""))
load(file = paste(selexDir, saveDir, "/data.kmerTable.RData", sep = ""))
#data.probeCounts.R3 = getProbeCounts(dataSample.R3, markovModel = mm)
#save(data.probeCounts.R3, file = paste(selexDir, saveDir, "/data.probeCounts.R3.RData", sep = ""))
load(file = paste(selexDir, saveDir, "/data.probeCounts.R3.RData", sep = ""))
# Inputs about library are data specific 
ModelTest = model(name = "HM-Exd-Ubx4a Nucleotides, no-symmetry",
                varRegLen = libLen,
                leftFixedSeq =  "GTTCAGAGTTCTACAGTCCGACGATCTGG", 
                rightFixedSeq ="CCAGCTGTCGTATGCCGTCTTCTGCTTG", 
                consensusSeq = "NTGAYNNAYNNN",
                affinityType = "AffinitySym",
                leftFixedSeqOverlap = 5,
                minAffinity = 0.00,
                missingValueSuppression = 1,
                minSeedValue = .001, 
                upFootprintExtend = 4,
                confidenceLevel = .95, 
                verbose = FALSE,
                rounds = list(c(2, 3)),
                rcSymmetric = FALSE)

getFeatureDesign(ModelTest)
## Feature design for object of class 'model'
## 
## seedLen:  12 
## upFootprintExtend:  4 
## downFootprintExtend:  4 
## rcSymmetric:  FALSE 
## 
## Slot "N": 
## N.upFootprintExtend:  4 
## N.downFootprintExtend:  4 
## N.set:  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 
## Number of previous iterations:  0 
## 
## Slot "Intercept": 
## Number of Views per Strand of DNA: 7
## Number of Rounds: 2 (2, 3)
## Number of previous iterations: 0
## 
## Slot "Shape": 
## "ShapeParamsUsed": NONE
# Add seed model
addSeedPsam(ModelTest) = seedTable2psam(ModelTest, data.kmerTable)

# Model nucleotide Betas after seed PSAM is added
print(getValues(getN(ModelTest)))
##     1 2 3 4          5          6          7         8         9        10
## N.A 0 0 0 0  0.0000000 -0.8340377 -0.6171102  0.000000 -1.360965 -1.476628
## N.C 0 0 0 0 -0.8162560 -1.8500362 -3.1650820 -2.675131 -1.992603 -2.448111
## N.G 0 0 0 0 -0.2525938 -2.1521858  0.0000000 -2.618543 -1.264517 -2.484039
## N.T 0 0 0 0 -0.4154319  0.0000000 -1.3143951 -2.908717  0.000000  0.000000
##            11        12        13          14         15         16 17 18
## N.A -1.118790  0.000000 -2.022527 -0.86831649  0.0000000 -0.7152829  0  0
## N.C -2.174582 -3.392451 -1.355055 -1.05294403 -1.6266289  0.0000000  0  0
## N.G -1.362605 -2.603949 -1.716115 -0.02638645 -0.0963874 -0.3890593  0  0
## N.T  0.000000 -3.561304  0.000000  0.00000000 -1.0818102 -0.2918482  0  0
##     19 20
## N.A  0  0
## N.C  0  0
## N.G  0  0
## N.T  0  0
plot(ModelTest@features@N, Ntitle = "HM-Ubx4a-Exd R2+R3 Nucleotide Features\nSeeding Model", ddG = TRUE)

Next we score the probes using topModelMatch

sample1 = sample(nrow(data.probeCounts), 500000)
sample2 = sample(nrow(data.probeCounts.R3), 500000)
data = rbind(data.probeCounts[sample1, ], data.probeCounts.R3[sample2,])
#data = rbind(data.probeCounts, data.probeCounts.R3)
data = topModelMatch(data, ModelTest)
# Uses aligned probes to build design matrix
data = addDesignMatrix(data, ModelTest)
designMatrixSummary = getDesignMatrix(ModelTest, data)
## No shape parameters included in fit.
print("Round summary: ")
## [1] "Round summary: "
print (designMatrixSummary$Round)
##            2      3  Total
## Round 396683 464232 860915
print("Mono-nucleotide summary: ")
## [1] "Mono-nucleotide summary: "
print (designMatrixSummary$N)
##       N.A    N.C    N.G    N.T
## 1   75514 199560 331991 253850
## 2  109766 175597 336439 239113
## 3  152429  93842 402970 211674
## 4  164680 116601 406719 172915
## 5  370370  62988 283365 144192
## 6  104337  21721  19442 715415
## 7  178377   2204 608470  71864
## 8  817832  12445  16700  13938
## 9   42398  16410  42530 759577
## 10  39374   9509  12299 799733
## 11  58362  13341  57417 731795
## 12 836448   5746  13577   5144
## 13  12814 102058  16011 730032
## 14 104690  48171 432746 275308
## 15 371861  49744 303128 136182
## 16 104105 397717 170797 188296
## 17 134102 442813 107989 176011
## 18 256044 349553  98378 156940
## 19 207001 315441 214664 123809
## 20 230394 388305 167856  74360
print("View/strand orientation summary: ")
## [1] "View/strand orientation summary: "
print (designMatrixSummary$Intercept)
##          View.1 View.2 View.3 View.4 View.5 View.6 View.7 StrandTotal
## Strand.F  53789  87849  80579  73852  75038  75639  89305      536051
## Strand.R  39171  55063  50947  39661  41036  43935  55051      324864
# # Constructs regression expression with independent features using design matrix
regressionFormula = updatedRegressionFormula(data, ModelTest)
print("Regression Formula: ")
## [1] "Regression Formula: "
print (regressionFormula)
## [1] "ObservedCount ~ offset(logProb)+Round.2+N.A1+N.C1+N.T1+N.A2+N.C2+N.T2+N.A3+N.C3+N.T3+N.A4+N.C4+N.T4+N.C5+N.G5+N.T5+N.A6+N.C6+N.G6+N.A7+N.C7+N.T7+N.C8+N.G8+N.T8+N.A9+N.C9+N.G9+N.A10+N.C10+N.G10+N.A11+N.C11+N.G11+N.C12+N.G12+N.T12+N.A13+N.C13+N.G13+N.A14+N.C14+N.T14+N.C15+N.G15+N.T15+N.A16+N.G16+N.T16+N.A17+N.G17+N.T17+N.A18+N.G18+N.T18+N.A19+N.G19+N.T19+N.A20+N.G20+N.T20"
fit = glm(regressionFormula, 
          data=data, 
          family = poisson(link="log"))
## Warning: glm.fit: fitted rates numerically 0 occurred
summary(fit)
## 
## Call:
## glm(formula = regressionFormula, family = poisson(link = "log"), 
##     data = data)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -14.8689   -0.9578   -0.3368    0.2486   17.1536  
## 
## Coefficients:
##               Estimate Std. Error  z value Pr(>|z|)    
## (Intercept) 26.1781175  0.0036421 7187.733   <2e-16 ***
## Round.2     -0.9313470  0.0017918 -519.778   <2e-16 ***
## N.A1         0.0262916  0.0010918   24.081   <2e-16 ***
## N.C1         0.0098712  0.0010120    9.754   <2e-16 ***
## N.T1        -0.0445393  0.0008265  -53.891   <2e-16 ***
## N.A2         0.0351747  0.0009274   37.928   <2e-16 ***
## N.C2        -0.0660371  0.0009651  -68.425   <2e-16 ***
## N.T2        -0.0421010  0.0008675  -48.533   <2e-16 ***
## N.A3         0.0216562  0.0007838   27.629   <2e-16 ***
## N.C3        -0.1224932  0.0009861 -124.218   <2e-16 ***
## N.T3        -0.1161729  0.0007926 -146.573   <2e-16 ***
## N.A4         0.0125909  0.0007427   16.953   <2e-16 ***
## N.C4        -0.1573905  0.0009365 -168.064   <2e-16 ***
## N.T4        -0.0706402  0.0007565  -93.376   <2e-16 ***
## N.C5        -0.7895035  0.0016076 -491.108   <2e-16 ***
## N.G5        -0.2883261  0.0006572 -438.714   <2e-16 ***
## N.T5        -0.4217330  0.0007443 -566.637   <2e-16 ***
## N.A6        -0.8695684  0.0014589 -596.047   <2e-16 ***
## N.C6        -1.6116968  0.0080345 -200.598   <2e-16 ***
## N.G6        -1.8783556  0.0122525 -153.304   <2e-16 ***
## N.A7        -0.6403078  0.0008225 -778.487   <2e-16 ***
## N.C7        -2.4817627  0.0739364  -33.566   <2e-16 ***
## N.T7        -1.1240562  0.0018239 -616.288   <2e-16 ***
## N.C8        -2.1709242  0.0228325  -95.080   <2e-16 ***
## N.G8        -2.0425258  0.0158577 -128.803   <2e-16 ***
## N.T8        -2.1640586  0.0168431 -128.484   <2e-16 ***
## N.A9        -1.2868781  0.0037114 -346.739   <2e-16 ***
## N.C9        -1.7931551  0.0124522 -144.003   <2e-16 ***
## N.G9        -1.2744780  0.0035761 -356.385   <2e-16 ***
## N.A10       -1.4297831  0.0042796 -334.090   <2e-16 ***
## N.C10       -2.0749872  0.0252099  -82.308   <2e-16 ***
## N.G10       -1.9616505  0.0210470  -93.203   <2e-16 ***
## N.A11       -1.0231291  0.0020594 -496.814   <2e-16 ***
## N.C11       -1.3538228  0.0093079 -145.449   <2e-16 ***
## N.G11       -0.9793158  0.0021775 -449.738   <2e-16 ***
## N.C12       -2.4345865  0.0513663  -47.397   <2e-16 ***
## N.G12       -2.0576933  0.0180386 -114.072   <2e-16 ***
## N.T12       -2.3525643  0.0382507  -61.504   <2e-16 ***
## N.A13       -1.8329160  0.0124866 -146.791   <2e-16 ***
## N.C13       -0.5625691  0.0011216 -501.563   <2e-16 ***
## N.G13       -1.6578347  0.0097312 -170.362   <2e-16 ***
## N.A14       -0.6294627  0.0011123 -565.906   <2e-16 ***
## N.C14       -0.7798483  0.0017850 -436.899   <2e-16 ***
## N.T14       -0.1479848  0.0005425 -272.766   <2e-16 ***
## N.C15       -0.9023721  0.0021536 -419.008   <2e-16 ***
## N.G15       -0.1182600  0.0005599 -211.212   <2e-16 ***
## N.T15       -0.5146147  0.0008720 -590.126   <2e-16 ***
## N.A16       -0.4537721  0.0009930 -456.962   <2e-16 ***
## N.G16       -0.2166355  0.0007381 -293.518   <2e-16 ***
## N.T16       -0.2559818  0.0007003 -365.550   <2e-16 ***
## N.A17       -0.1760533  0.0008456 -208.209   <2e-16 ***
## N.G17       -0.2436129  0.0009636 -252.808   <2e-16 ***
## N.T17       -0.0756030  0.0007380 -102.443   <2e-16 ***
## N.A18       -0.1075614  0.0008981 -119.769   <2e-16 ***
## N.G18       -0.0940778  0.0010222  -92.034   <2e-16 ***
## N.T18        0.0643701  0.0008196   78.534   <2e-16 ***
## N.A19       -0.0514118  0.0010067  -51.070   <2e-16 ***
## N.G19       -0.1200973  0.0010110 -118.794   <2e-16 ***
## N.T19        0.1058977  0.0009521  111.222   <2e-16 ***
## N.A20       -0.0174591  0.0008012  -21.790   <2e-16 ***
## N.G20       -0.0668591  0.0010975  -60.920   <2e-16 ***
## N.T20        0.0685072  0.0011186   61.243   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 6054923  on 860914  degrees of freedom
## Residual deviance: 1457917  on 860853  degrees of freedom
## AIC: 2656353
## 
## Number of Fisher Scoring iterations: 9
ModelTest = addNewBetas(ModelTest, data, fit)
## No shape parameters included in fit.
# # Nucleotide Features after first round of fitting
summary(ModelTest)
## An object of class 'model'
## 
## Slot "name":  HM-Exd-Ubx4a Nucleotides, no-symmetry 
## Slot "varRegLen":  16 
## Slot "leftFixedSeq":  GTTCAGAGTTCTACAGTCCGACGATCTGG 
## Slot "rightFixedSeq":  CCAGCTGTCGTATGCCGTCTTCTGCTTG 
## Slot "leftFixedSeqOverlap":  5 
## Slot "rightFixedSeqOverlap":  5 
## Slot "confidenceLevel":  0.95 
## Slot "minAffinity":  0 
## Slot "missingValueSuppression":  1 
## Slot "minSeedValue":  0.001 
## Slot "seedLen":  12 
## Slot "consensusSeq":  [ACGT]TGA[CT][ACGT][ACGT]A[CT][ACGT][ACGT][ACGT] 
## Slot "upFootprintExtend":  4 
## Slot "downFootprintExtend":  4 
## Slot "fpLen":  20 
## 
## Fits a model of footprint length 20 for mono-nucleotide features  with 7 view(s) per strand of DNA and 2 round(s) of data (round = 2, 3) without reverse complement symmetry.
## 
## Slot "regressionFormula":  ObservedCount ~ offset(logProb)+Round.2+Round.3+N.A1+N.C1+N.G1+N.T1+N.A2+N.C2+N.G2+N.T2+N.A3+N.C3+N.G3+N.T3+N.A4+N.C4+N.G4+N.T4+N.A5+N.C5+N.G5+N.T5+N.A6+N.C6+N.G6+N.T6+N.A7+N.C7+N.G7+N.T7+N.A8+N.C8+N.G8+N.T8+N.A9+N.C9+N.G9+N.T9+N.A10+N.C10+N.G10+N.T10+N.A11+N.C11+N.G11+N.T11+N.A12+N.C12+N.G12+N.T12+N.A13+N.C13+N.G13+N.T13+N.A14+N.C14+N.G14+N.T14+N.A15+N.C15+N.G15+N.T15+N.A16+N.C16+N.G16+N.T16+N.A17+N.C17+N.G17+N.T17+N.A18+N.C18+N.G18+N.T18+N.A19+N.C19+N.G19+N.T19+N.A20+N.C20+N.G20+N.T20 
## 
## 
## Includes the following feature sub-classes: 
## An object of class 'N'
## Fits 20 nucleotides for a feature model of length 20.
## Nucleotide beta values:
##                1           2           3           4          5          6
## N.A  0.026291559  0.03517468  0.02165625  0.01259090  0.0000000 -0.8695684
## N.C  0.009871185 -0.06603707 -0.12249317 -0.15739051 -0.7895035 -1.6116968
## N.G  0.000000000  0.00000000  0.00000000  0.00000000 -0.2883261 -1.8783556
## N.T -0.044539268 -0.04210096 -0.11617291 -0.07064019 -0.4217330  0.0000000
##              7         8         9        10         11        12
## N.A -0.6403078  0.000000 -1.286878 -1.429783 -1.0231291  0.000000
## N.C -2.4817627 -2.170924 -1.793155 -2.074987 -1.3538228 -2.434586
## N.G  0.0000000 -2.042526 -1.274478 -1.961650 -0.9793158 -2.057693
## N.T -1.1240562 -2.164059  0.000000  0.000000  0.0000000 -2.352564
##             13         14         15         16          17          18
## N.A -1.8329160 -0.6294627  0.0000000 -0.4537721 -0.17605331 -0.10756141
## N.C -0.5625691 -0.7798483 -0.9023721  0.0000000  0.00000000  0.00000000
## N.G -1.6578347  0.0000000 -0.1182600 -0.2166355 -0.24361292 -0.09407783
## N.T  0.0000000 -0.1479848 -0.5146147 -0.2559818 -0.07560298  0.06437008
##              19          20
## N.A -0.05141179 -0.01745912
## N.C  0.00000000  0.00000000
## N.G -0.12009729 -0.06685912
## N.T  0.10589767  0.06850716
## 
## Nucleotide beta errors:
##                1            2            3            4            5
## N.A 0.0010918055 0.0009274159 0.0007838279 0.0007427130 0.0000000000
## N.C 0.0010119973 0.0009651061 0.0009861179 0.0009364935 0.0016075966
## N.G 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0006572079
## N.T 0.0008264673 0.0008674770 0.0007925964 0.0007565134 0.0007442741
##               6            7          8           9          10
## N.A 0.001458893 0.0008225027 0.00000000 0.003711375 0.004279632
## N.C 0.008034476 0.0739363690 0.02283253 0.012452179 0.025209940
## N.G 0.012252479 0.0000000000 0.01585771 0.003576129 0.021047000
## N.T 0.000000000 0.0018239152 0.01684305 0.000000000 0.000000000
##              11         12          13          14           15
## N.A 0.002059382 0.00000000 0.012486554 0.001112309 0.0000000000
## N.C 0.009307872 0.05136626 0.001121633 0.001784961 0.0021535909
## N.G 0.002177525 0.01803857 0.009731224 0.000000000 0.0005599107
## N.T 0.000000000 0.03825068 0.000000000 0.000542534 0.0008720417
##               16           17           18           19           20
## N.A 0.0009930186 0.0008455614 0.0008980725 0.0010066892 0.0008012335
## N.C 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000
## N.G 0.0007380663 0.0009636300 0.0010222086 0.0010109682 0.0010974963
## N.T 0.0007002639 0.0007380020 0.0008196440 0.0009521272 0.0011186067
## 
## 
## An object of class 'Intercept'
## Fits intercept(s) for 2 round(s) (round = 2, 3).
## Intercept beta values:
## Round.2:
## [1] 25.24677
## 
## Round.3:
## [1] 26.17812
## 
## Intercept beta errors:
## Round.2:
## [1] 0.004058962
## 
## Round.3:
## [1] 0.003642055
## 
## 
## 
## An object of class 'Shape'
## Fits 0 shape coefficients for 0 kinds of shape parameter(s) (shape = ) for a feature model of length 20.
vPheight = verticalPlot_height(ModelTest)
pM <- plot(ModelTest, plotTitle = "HM-Ubx4a-Exd R2+R3 Nucleotide Fit", Nplot.ddG = TRUE, verticalPlots = TRUE)
ggplot2::ggsave(pM, file = paste(selexDir, saveDir, "/modelPlot.pdf", sep = ""), height = vPheight, width = 6)
ggplot2::ggsave(pM, file = paste(selexDir, saveDir, "/modelPlot.",1, ".pdf", sep = ""), height = vPheight, width = 6)

some text

data = rbind(data.probeCounts[sample1, ], data.probeCounts.R3[sample2,])
#data = rbind(data.probeCounts, data.probeCounts.R3)
data.nrow = nrow(data)
data = topModelMatch(data, ModelTest)
data = addDesignMatrix(data, ModelTest)
designMatrixSummary.v2 = getDesignMatrix(ModelTest, data)
## No shape parameters included in fit.
if ((all(designMatrixSummary.v2$N == designMatrixSummary$N)) & (all(designMatrixSummary.v2$Round == designMatrixSummary$Round)) & (all(designMatrixSummary.v2$Intercept == designMatrixSummary$Intercept)))  {
  print ("Stability Reached")
}
for (i in 2:20) {
  if (data.nrow == nrow(data)) {
    break
  }
  data.nrow = nrow(data)
  print (paste("i =",i))
  
  designMatrixSummary = getDesignMatrix(ModelTest, data)
  print("Round summary: ")
  print (designMatrixSummary$Round)
  print("Mono-nucleotide summary: ")
  print (designMatrixSummary$N)
  print("View/strand orientation summary: ")
  print (designMatrixSummary$Intercept)
  # # Constructs regression expression with independent features using design matrix
  regressionFormula = updatedRegressionFormula(data, ModelTest)
  print("Regression Formula: ")
  print (regressionFormula)
  fit = glm(regressionFormula, 
            data=data, 
            family = poisson(link="log"))
  summary(fit)
  ModelTest = addNewBetas(ModelTest, data, fit)
  # # Nucleotide Features after first round of fitting
  summary(ModelTest)
  pM <- plot(ModelTest, plotTitle = "HM-Ubx4a-Exd R2+R3 Nucleotide Fit", Nplot.ddG = TRUE, verticalPlots = TRUE)
  ggplot2::ggsave(pM, file = paste(selexDir, saveDir, "/modelPlot.",i, ".pdf", sep = ""), height = vPheight, width = 6)
  ggplot2::ggsave(pM, file = paste(selexDir, saveDir, "/modelPlot.pdf", sep = ""), height = vPheight, width = 6)
  data = topModelMatch(data, ModelTest)
  data = addDesignMatrix(data, ModelTest)
  print(paste("Number of Observations in Design Matrix: ",nrow(data), sep = ""))
  designMatrixSummary.v2 = getDesignMatrix(ModelTest, data)
if ((all(designMatrixSummary.v2$N == designMatrixSummary$N)) & (all(designMatrixSummary.v2$Round == designMatrixSummary$Round)) & (all(designMatrixSummary.v2$Intercept == designMatrixSummary$Intercept)))  {
    print (paste("Stability Reached after ", i, " iterations.", sep = ""))
    break
  } else if (nrow(data) == 0) {
    print ("Algorithm failed to converge: No probes meet the confidence level requirement (Confidence Level:", ModelTest@confidenceLevel, ")", sep = "")
  }
}
## [1] "i = 2"
## No shape parameters included in fit.
## [1] "Round summary: "
##            2      3  Total
## Round 376135 459421 835556
## [1] "Mono-nucleotide summary: "
##       N.A    N.C    N.G    N.T
## 1   71695 195972 321251 246638
## 2  106256 168658 328628 232014
## 3  147299  91129 394391 202737
## 4  161263 110880 395912 167501
## 5  364017  60987 270929 139623
## 6   96120  20308  16193 702935
## 7  170749   2055 593859  68893
## 8  797615  10810  13878  13253
## 9   33873  13204  36996 751483
## 10  32935   7636  10374 784611
## 11  50944  12935  54870 716807
## 12 811724   6067  11703   6062
## 13   9763 105641  12596 707556
## 14 103041  47347 427750 257418
## 15 356268  50021 291393 137874
## 16 101177 384031 170438 179910
## 17 130537 428812 104595 171612
## 18 246002 339076  95444 155034
## 19 200003 307380 206063 122110
## 20 222762 378156 162245  72393
## [1] "View/strand orientation summary: "
##          View.1 View.2 View.3 View.4 View.5 View.6 View.7 StrandTotal
## Strand.F  51639  86606  79318  72492  72830  73074  85115      521074
## Strand.R  37567  54008  50073  38639  39591  42133  52471      314482
## [1] "Regression Formula: "
## [1] "ObservedCount ~ offset(logProb)+Round.2+N.A1+N.C1+N.T1+N.A2+N.C2+N.T2+N.A3+N.C3+N.T3+N.A4+N.C4+N.T4+N.C5+N.G5+N.T5+N.A6+N.C6+N.G6+N.A7+N.C7+N.T7+N.C8+N.G8+N.T8+N.A9+N.C9+N.G9+N.A10+N.C10+N.G10+N.A11+N.C11+N.G11+N.C12+N.G12+N.T12+N.A13+N.C13+N.G13+N.A14+N.C14+N.T14+N.C15+N.G15+N.T15+N.A16+N.G16+N.T16+N.A17+N.G17+N.T17+N.A18+N.G18+N.T18+N.A19+N.G19+N.T19+N.A20+N.G20+N.T20"
## No shape parameters included in fit.
## An object of class 'model'
## 
## Slot "name":  HM-Exd-Ubx4a Nucleotides, no-symmetry 
## Slot "varRegLen":  16 
## Slot "leftFixedSeq":  GTTCAGAGTTCTACAGTCCGACGATCTGG 
## Slot "rightFixedSeq":  CCAGCTGTCGTATGCCGTCTTCTGCTTG 
## Slot "leftFixedSeqOverlap":  5 
## Slot "rightFixedSeqOverlap":  5 
## Slot "confidenceLevel":  0.95 
## Slot "minAffinity":  0 
## Slot "missingValueSuppression":  1 
## Slot "minSeedValue":  0.001 
## Slot "seedLen":  12 
## Slot "consensusSeq":  [ACGT]TGA[CT][ACGT][ACGT]A[CT][ACGT][ACGT][ACGT] 
## Slot "upFootprintExtend":  4 
## Slot "downFootprintExtend":  4 
## Slot "fpLen":  20 
## 
## Fits a model of footprint length 20 for mono-nucleotide features  with 7 view(s) per strand of DNA and 2 round(s) of data (round = 2, 3) without reverse complement symmetry.
## 
## Slot "regressionFormula":  ObservedCount ~ offset(logProb)+Round.2+Round.3+N.A1+N.C1+N.G1+N.T1+N.A2+N.C2+N.G2+N.T2+N.A3+N.C3+N.G3+N.T3+N.A4+N.C4+N.G4+N.T4+N.A5+N.C5+N.G5+N.T5+N.A6+N.C6+N.G6+N.T6+N.A7+N.C7+N.G7+N.T7+N.A8+N.C8+N.G8+N.T8+N.A9+N.C9+N.G9+N.T9+N.A10+N.C10+N.G10+N.T10+N.A11+N.C11+N.G11+N.T11+N.A12+N.C12+N.G12+N.T12+N.A13+N.C13+N.G13+N.T13+N.A14+N.C14+N.G14+N.T14+N.A15+N.C15+N.G15+N.T15+N.A16+N.C16+N.G16+N.T16+N.A17+N.C17+N.G17+N.T17+N.A18+N.C18+N.G18+N.T18+N.A19+N.C19+N.G19+N.T19+N.A20+N.C20+N.G20+N.T20 
## 
## 
## Includes the following feature sub-classes: 
## An object of class 'N'
## Fits 20 nucleotides for a feature model of length 20.
## Nucleotide beta values:
##                1           2           3           4          5          6
## N.A  0.026462679  0.03527034  0.02155505  0.01214840  0.0000000 -0.8692177
## N.C  0.009519406 -0.06576296 -0.12296153 -0.15703815 -0.7892678 -1.6119673
## N.G  0.000000000  0.00000000  0.00000000  0.00000000 -0.2877967 -1.8911188
## N.T -0.044519232 -0.04153710 -0.11645340 -0.07045342 -0.4211381  0.0000000
##              7         8         9        10         11        12
## N.A -0.6407228  0.000000 -1.275271 -1.429216 -1.0150900  0.000000
## N.C -2.5778524 -2.183092 -1.799039 -2.110501 -1.3398638 -2.409188
## N.G  0.0000000 -2.071588 -1.275309 -1.979032 -0.9801195 -2.066346
## N.T -1.1250503 -2.165210  0.000000  0.000000  0.0000000 -2.352951
##            13         14         15         16          17          18
## N.A -1.844328 -0.6286418  0.0000000 -0.4533564 -0.17615502 -0.10761165
## N.C -0.562126 -0.7804193 -0.9016697  0.0000000  0.00000000  0.00000000
## N.G -1.655499  0.0000000 -0.1185571 -0.2165623 -0.24349059 -0.09449161
## N.T  0.000000 -0.1474689 -0.5139725 -0.2557485 -0.07540824  0.06422439
##              19          20
## N.A -0.05099609 -0.01757505
## N.C  0.00000000  0.00000000
## N.G -0.11972047 -0.06719864
## N.T  0.10597301  0.06808539
## 
## Nucleotide beta errors:
##                1            2            3            4            5
## N.A 0.0010934728 0.0009278856 0.0007843290 0.0007428868 0.0000000000
## N.C 0.0010127430 0.0009662239 0.0009862563 0.0009386911 0.0016084496
## N.G 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0006579489
## N.T 0.0008272209 0.0008683590 0.0007927631 0.0007566550 0.0007447128
##               6            7          8           9          10
## N.A 0.001461370 0.0008220558 0.00000000 0.003886721 0.004389374
## N.C 0.008019163 0.0823858904 0.02322770 0.012711780 0.026648347
## N.G 0.012588822 0.0000000000 0.01665974 0.003593546 0.021882235
## N.T 0.000000000 0.0018246082 0.01684335 0.000000000 0.000000000
##              11         12          13           14           15
## N.A 0.002080612 0.00000000 0.012783386 0.0011117964 0.0000000000
## N.C 0.009122609 0.04950916 0.001116705 0.0017819469 0.0021486843
## N.G 0.002180945 0.01831873 0.009781631 0.0000000000 0.0005604478
## N.T 0.000000000 0.03707909 0.000000000 0.0005432739 0.0008703152
##               16           17           18           19           20
## N.A 0.0009930684 0.0008458215 0.0008982657 0.0010071903 0.0008017088
## N.C 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000
## N.G 0.0007375597 0.0009640844 0.0010228516 0.0010114224 0.0010980458
## N.T 0.0007011001 0.0007379849 0.0008195246 0.0009525917 0.0011190661
## 
## 
## An object of class 'Intercept'
## Fits intercept(s) for 2 round(s) (round = 2, 3).
## Intercept beta values:
## Round.2:
## [1] 25.24721
## 
## Round.3:
## [1] 26.17594
## 
## Intercept beta errors:
## Round.2:
## [1] 0.004062728
## 
## Round.3:
## [1] 0.003644745
## 
## 
## 
## An object of class 'Shape'
## Fits 0 shape coefficients for 0 kinds of shape parameter(s) (shape = ) for a feature model of length 20.
## [1] "Number of Observations in Design Matrix: 834539"
## No shape parameters included in fit.
## [1] "i = 3"
## No shape parameters included in fit.
## [1] "Round summary: "
##            2      3  Total
## Round 375487 459052 834539
## [1] "Mono-nucleotide summary: "
##       N.A    N.C    N.G    N.T
## 1   71574 195802 320770 246393
## 2  106106 168480 328165 231788
## 3  147095  90975 394036 202433
## 4  160971 110682 395573 167313
## 5  363452  60927 270645 139515
## 6   96030  20275  16092 702142
## 7  170374   1878 593554  68733
## 8  796826  10760  13734  13219
## 9   33833  13134  36922 750650
## 10  32917   7553  10295 783774
## 11  50908  12909  54796 715926
## 12 810788   6062  11656   6033
## 13   9701 105520  12557 706761
## 14 102859  47250 427437 256993
## 15 355830  49921 291097 137691
## 16 101034 383534 170272 179699
## 17 130402 428256 104478 171403
## 18 245698 338605  95356 154880
## 19 199767 306936 205823 122013
## 20 222458 377704 162044  72333
## [1] "View/strand orientation summary: "
##          View.1 View.2 View.3 View.4 View.5 View.6 View.7 StrandTotal
## Strand.F  51591  86532  79248  72385  72704  72981  84991      520432
## Strand.R  37542  53980  50031  38571  39522  42061  52400      314107
## [1] "Regression Formula: "
## [1] "ObservedCount ~ offset(logProb)+Round.2+N.A1+N.C1+N.T1+N.A2+N.C2+N.T2+N.A3+N.C3+N.T3+N.A4+N.C4+N.T4+N.C5+N.G5+N.T5+N.A6+N.C6+N.G6+N.A7+N.C7+N.T7+N.C8+N.G8+N.T8+N.A9+N.C9+N.G9+N.A10+N.C10+N.G10+N.A11+N.C11+N.G11+N.C12+N.G12+N.T12+N.A13+N.C13+N.G13+N.A14+N.C14+N.T14+N.C15+N.G15+N.T15+N.A16+N.G16+N.T16+N.A17+N.G17+N.T17+N.A18+N.G18+N.T18+N.A19+N.G19+N.T19+N.A20+N.G20+N.T20"
## No shape parameters included in fit.
## An object of class 'model'
## 
## Slot "name":  HM-Exd-Ubx4a Nucleotides, no-symmetry 
## Slot "varRegLen":  16 
## Slot "leftFixedSeq":  GTTCAGAGTTCTACAGTCCGACGATCTGG 
## Slot "rightFixedSeq":  CCAGCTGTCGTATGCCGTCTTCTGCTTG 
## Slot "leftFixedSeqOverlap":  5 
## Slot "rightFixedSeqOverlap":  5 
## Slot "confidenceLevel":  0.95 
## Slot "minAffinity":  0 
## Slot "missingValueSuppression":  1 
## Slot "minSeedValue":  0.001 
## Slot "seedLen":  12 
## Slot "consensusSeq":  [ACGT]TGA[CT][ACGT][ACGT]A[CT][ACGT][ACGT][ACGT] 
## Slot "upFootprintExtend":  4 
## Slot "downFootprintExtend":  4 
## Slot "fpLen":  20 
## 
## Fits a model of footprint length 20 for mono-nucleotide features  with 7 view(s) per strand of DNA and 2 round(s) of data (round = 2, 3) without reverse complement symmetry.
## 
## Slot "regressionFormula":  ObservedCount ~ offset(logProb)+Round.2+Round.3+N.A1+N.C1+N.G1+N.T1+N.A2+N.C2+N.G2+N.T2+N.A3+N.C3+N.G3+N.T3+N.A4+N.C4+N.G4+N.T4+N.A5+N.C5+N.G5+N.T5+N.A6+N.C6+N.G6+N.T6+N.A7+N.C7+N.G7+N.T7+N.A8+N.C8+N.G8+N.T8+N.A9+N.C9+N.G9+N.T9+N.A10+N.C10+N.G10+N.T10+N.A11+N.C11+N.G11+N.T11+N.A12+N.C12+N.G12+N.T12+N.A13+N.C13+N.G13+N.T13+N.A14+N.C14+N.G14+N.T14+N.A15+N.C15+N.G15+N.T15+N.A16+N.C16+N.G16+N.T16+N.A17+N.C17+N.G17+N.T17+N.A18+N.C18+N.G18+N.T18+N.A19+N.C19+N.G19+N.T19+N.A20+N.C20+N.G20+N.T20 
## 
## 
## Includes the following feature sub-classes: 
## An object of class 'N'
## Fits 20 nucleotides for a feature model of length 20.
## Nucleotide beta values:
##                1           2           3           4          5          6
## N.A  0.026482751  0.03526733  0.02155224  0.01220516  0.0000000 -0.8692458
## N.C  0.009540026 -0.06575718 -0.12290849 -0.15706252 -0.7892854 -1.6119281
## N.G  0.000000000  0.00000000  0.00000000  0.00000000 -0.2878248 -1.8916493
## N.T -0.044522030 -0.04155492 -0.11642683 -0.07045358 -0.4211542  0.0000000
##              7         8         9        10         11        12
## N.A -0.6406178  0.000000 -1.275095 -1.429243 -1.0150920  0.000000
## N.C -2.7238745 -2.183898 -1.798782 -2.112268 -1.3392841 -2.409205
## N.G  0.0000000 -2.075230 -1.275289 -1.977448 -0.9801764 -2.066809
## N.T -1.1249311 -2.166724  0.000000  0.000000  0.0000000 -2.351845
##             13         14         15         16          17          18
## N.A -1.8436289 -0.6285929  0.0000000 -0.4533057 -0.17612835 -0.10762155
## N.C -0.5621454 -0.7803760 -0.9016096  0.0000000  0.00000000  0.00000000
## N.G -1.6554351  0.0000000 -0.1185660 -0.2165527 -0.24347690 -0.09448428
## N.T  0.0000000 -0.1474546 -0.5139782 -0.2557464 -0.07539279  0.06420238
##              19          20
## N.A -0.05098977 -0.01757241
## N.C  0.00000000  0.00000000
## N.G -0.11970212 -0.06719989
## N.T  0.10598369  0.06808189
## 
## Nucleotide beta errors:
##               1            2            3            4            5
## N.A 0.001093592 0.0009279777 0.0007843706 0.0007429232 0.0000000000
## N.C 0.001012789 0.0009663028 0.0009863507 0.0009388670 0.0016084919
## N.G 0.000000000 0.0000000000 0.0000000000 0.0000000000 0.0006579925
## N.T 0.000827259 0.0008684325 0.0007928539 0.0007566812 0.0007447274
##               6            7          8           9          10
## N.A 0.001461428 0.0008223808 0.00000000 0.003886614 0.004389408
## N.C 0.008019209 0.1027989951 0.02325549 0.012725807 0.026793579
## N.G 0.012601787 0.0000000000 0.01676857 0.003593536 0.021877725
## N.T 0.000000000 0.0018248430 0.01687583 0.000000000 0.000000000
##              11         12          13           14           15
## N.A 0.002080641 0.00000000 0.012782155 0.0011119416 0.0000000000
## N.C 0.009123106 0.04950935 0.001116796 0.0017822713 0.0021488610
## N.G 0.002181160 0.01833241 0.009781578 0.0000000000 0.0005604787
## N.T 0.000000000 0.03707370 0.000000000 0.0005433037 0.0008703847
##               16           17           18           19           20
## N.A 0.0009931400 0.0008458524 0.0008982889 0.0010072109 0.0008017673
## N.C 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000
## N.G 0.0007375892 0.0009641565 0.0010228817 0.0010114513 0.0010980725
## N.T 0.0007011471 0.0007380176 0.0008195583 0.0009526087 0.0011190928
## 
## 
## An object of class 'Intercept'
## Fits intercept(s) for 2 round(s) (round = 2, 3).
## Intercept beta values:
## Round.2:
## [1] 25.24724
## 
## Round.3:
## [1] 26.17581
## 
## Intercept beta errors:
## Round.2:
## [1] 0.004062956
## 
## Round.3:
## [1] 0.003644913
## 
## 
## 
## An object of class 'Shape'
## Fits 0 shape coefficients for 0 kinds of shape parameter(s) (shape = ) for a feature model of length 20.
## [1] "Number of Observations in Design Matrix: 834279"
## No shape parameters included in fit.
## [1] "i = 4"
## No shape parameters included in fit.
## [1] "Round summary: "
##            2      3  Total
## Round 375341 458938 834279
## [1] "Mono-nucleotide summary: "
##       N.A    N.C    N.G    N.T
## 1   71554 195751 320659 246315
## 2  106087 168428 328048 231716
## 3  147049  90956 393904 202370
## 4  160925 110656 395444 167254
## 5  363338  60905 270562 139474
## 6   95979  20269  16083 701948
## 7  170364   1653 593537  68725
## 8  796626  10745  13708  13200
## 9   33807  13123  36901 750448
## 10  32914   7546  10291 783528
## 11  50900  12893  54767 715719
## 12 810559   6053  11641   6026
## 13   9695 105458  12547 706579
## 14 102832  47230 427304 256913
## 15 355750  49897 290980 137652
## 16 101002 383418 170204 179655
## 17 130335 428148 104445 171351
## 18 245616 338512  95324 154827
## 19 199719 306824 205770 121966
## 20 222384 377570 162011  72314
## [1] "View/strand orientation summary: "
##          View.1 View.2 View.3 View.4 View.5 View.6 View.7 StrandTotal
## Strand.F  51577  86508  79219  72357  72670  72965  84974      520270
## Strand.R  37527  53961  50006  38558  39517  42054  52386      314009
## [1] "Regression Formula: "
## [1] "ObservedCount ~ offset(logProb)+Round.2+N.A1+N.C1+N.T1+N.A2+N.C2+N.T2+N.A3+N.C3+N.T3+N.A4+N.C4+N.T4+N.C5+N.G5+N.T5+N.A6+N.C6+N.G6+N.A7+N.C7+N.T7+N.C8+N.G8+N.T8+N.A9+N.C9+N.G9+N.A10+N.C10+N.G10+N.A11+N.C11+N.G11+N.C12+N.G12+N.T12+N.A13+N.C13+N.G13+N.A14+N.C14+N.T14+N.C15+N.G15+N.T15+N.A16+N.G16+N.T16+N.A17+N.G17+N.T17+N.A18+N.G18+N.T18+N.A19+N.G19+N.T19+N.A20+N.G20+N.T20"
## No shape parameters included in fit.
## An object of class 'model'
## 
## Slot "name":  HM-Exd-Ubx4a Nucleotides, no-symmetry 
## Slot "varRegLen":  16 
## Slot "leftFixedSeq":  GTTCAGAGTTCTACAGTCCGACGATCTGG 
## Slot "rightFixedSeq":  CCAGCTGTCGTATGCCGTCTTCTGCTTG 
## Slot "leftFixedSeqOverlap":  5 
## Slot "rightFixedSeqOverlap":  5 
## Slot "confidenceLevel":  0.95 
## Slot "minAffinity":  0 
## Slot "missingValueSuppression":  1 
## Slot "minSeedValue":  0.001 
## Slot "seedLen":  12 
## Slot "consensusSeq":  [ACGT]TGA[CT][ACGT][ACGT]A[CT][ACGT][ACGT][ACGT] 
## Slot "upFootprintExtend":  4 
## Slot "downFootprintExtend":  4 
## Slot "fpLen":  20 
## 
## Fits a model of footprint length 20 for mono-nucleotide features  with 7 view(s) per strand of DNA and 2 round(s) of data (round = 2, 3) without reverse complement symmetry.
## 
## Slot "regressionFormula":  ObservedCount ~ offset(logProb)+Round.2+Round.3+N.A1+N.C1+N.G1+N.T1+N.A2+N.C2+N.G2+N.T2+N.A3+N.C3+N.G3+N.T3+N.A4+N.C4+N.G4+N.T4+N.A5+N.C5+N.G5+N.T5+N.A6+N.C6+N.G6+N.T6+N.A7+N.C7+N.G7+N.T7+N.A8+N.C8+N.G8+N.T8+N.A9+N.C9+N.G9+N.T9+N.A10+N.C10+N.G10+N.T10+N.A11+N.C11+N.G11+N.T11+N.A12+N.C12+N.G12+N.T12+N.A13+N.C13+N.G13+N.T13+N.A14+N.C14+N.G14+N.T14+N.A15+N.C15+N.G15+N.T15+N.A16+N.C16+N.G16+N.T16+N.A17+N.C17+N.G17+N.T17+N.A18+N.C18+N.G18+N.T18+N.A19+N.C19+N.G19+N.T19+N.A20+N.C20+N.G20+N.T20 
## 
## 
## Includes the following feature sub-classes: 
## An object of class 'N'
## Fits 20 nucleotides for a feature model of length 20.
## Nucleotide beta values:
##                1           2           3           4          5          6
## N.A  0.026482189  0.03526756  0.02155358  0.01220696  0.0000000 -0.8692467
## N.C  0.009538379 -0.06575797 -0.12290828 -0.15706183 -0.7892861 -1.6119300
## N.G  0.000000000  0.00000000  0.00000000  0.00000000 -0.2878242 -1.8916495
## N.T -0.044522679 -0.04155334 -0.11642779 -0.07045319 -0.4211544  0.0000000
##              7         8         9        10         11        12
## N.A -0.6406199  0.000000 -1.275110 -1.429245 -1.0150935  0.000000
## N.C -2.7257488 -2.183885 -1.798784 -2.112074 -1.3392859 -2.409205
## N.G  0.0000000 -2.076382 -1.275316 -1.977451 -0.9801776 -2.066354
## N.T -1.1249374 -2.166720  0.000000  0.000000  0.0000000 -2.351845
##            13         14         15         16          17          18
## N.A -1.843629 -0.6285941  0.0000000 -0.4533064 -0.17612721 -0.10762321
## N.C -0.562148 -0.7803892 -0.9016109  0.0000000  0.00000000  0.00000000
## N.G -1.655437  0.0000000 -0.1185666 -0.2165528 -0.24347740 -0.09448532
## N.T  0.000000 -0.1474551 -0.5139788 -0.2557481 -0.07539191  0.06420289
##              19          20
## N.A -0.05098894 -0.01757234
## N.C  0.00000000  0.00000000
## N.G -0.11969939 -0.06719835
## N.T  0.10598625  0.06808155
## 
## Nucleotide beta errors:
##                1            2            3            4            5
## N.A 0.0010935925 0.0009279781 0.0007843717 0.0007429238 0.0000000000
## N.C 0.0010127902 0.0009663038 0.0009863511 0.0009388686 0.0016084920
## N.G 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0006579925
## N.T 0.0008272603 0.0008684330 0.0007928551 0.0007566820 0.0007447276
##               6            7          8           9          10
## N.A 0.001461428 0.0008223838 0.00000000 0.003886868 0.004389409
## N.C 0.008019211 0.1078810584 0.02325545 0.012725810 0.026792553
## N.G 0.012601786 0.0000000000 0.01679552 0.003593650 0.021877729
## N.T 0.000000000 0.0018248568 0.01687581 0.000000000 0.000000000
##              11         12          13           14           15
## N.A 0.002080641 0.00000000 0.012782153 0.0011119417 0.0000000000
## N.C 0.009123107 0.04950934 0.001116799 0.0017822987 0.0021488611
## N.G 0.002181160 0.01833106 0.009781580 0.0000000000 0.0005604796
## N.T 0.000000000 0.03707370 0.000000000 0.0005433043 0.0008703847
##               16           17           18           19          20
## N.A 0.0009931400 0.0008458528 0.0008982906 0.0010072127 0.000801769
## N.C 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.000000000
## N.G 0.0007375898 0.0009641581 0.0010228836 0.0010114523 0.001098073
## N.T 0.0007011484 0.0007380189 0.0008195591 0.0009526098 0.001119095
## 
## 
## An object of class 'Intercept'
## Fits intercept(s) for 2 round(s) (round = 2, 3).
## Intercept beta values:
## Round.2:
## [1] 25.24724
## 
## Round.3:
## [1] 26.17581
## 
## Intercept beta errors:
## Round.2:
## [1] 0.004062965
## 
## Round.3:
## [1] 0.003644921
## 
## 
## 
## An object of class 'Shape'
## Fits 0 shape coefficients for 0 kinds of shape parameter(s) (shape = ) for a feature model of length 20.
## [1] "Number of Observations in Design Matrix: 834273"
## No shape parameters included in fit.
## [1] "i = 5"
## No shape parameters included in fit.
## [1] "Round summary: "
##            2      3  Total
## Round 375338 458935 834273
## [1] "Mono-nucleotide summary: "
##       N.A    N.C    N.G    N.T
## 1   71553 195750 320658 246312
## 2  106085 168427 328045 231716
## 3  147048  90956 393902 202367
## 4  160924 110655 395441 167253
## 5  363335  60905 270560 139473
## 6   95978  20269  16083 701943
## 7  170364   1650 593534  68725
## 8  796624  10745  13706  13198
## 9   33806  13122  36901 750444
## 10  32914   7546  10290 783523
## 11  50900  12892  54766 715715
## 12 810553   6053  11641   6026
## 13   9695 105455  12547 706576
## 14 102831  47229 427300 256913
## 15 355748  49896 290980 137649
## 16 101002 383415 170203 179653
## 17 130334 428143 104445 171351
## 18 245612 338510  95324 154827
## 19 199715 306823 205769 121966
## 20 222382 377568 162009  72314
## [1] "View/strand orientation summary: "
##          View.1 View.2 View.3 View.4 View.5 View.6 View.7 StrandTotal
## Strand.F  51577  86508  79217  72357  72670  72963  84974      520266
## Strand.R  37526  53961  50006  38558  39517  42054  52385      314007
## [1] "Regression Formula: "
## [1] "ObservedCount ~ offset(logProb)+Round.2+N.A1+N.C1+N.T1+N.A2+N.C2+N.T2+N.A3+N.C3+N.T3+N.A4+N.C4+N.T4+N.C5+N.G5+N.T5+N.A6+N.C6+N.G6+N.A7+N.C7+N.T7+N.C8+N.G8+N.T8+N.A9+N.C9+N.G9+N.A10+N.C10+N.G10+N.A11+N.C11+N.G11+N.C12+N.G12+N.T12+N.A13+N.C13+N.G13+N.A14+N.C14+N.T14+N.C15+N.G15+N.T15+N.A16+N.G16+N.T16+N.A17+N.G17+N.T17+N.A18+N.G18+N.T18+N.A19+N.G19+N.T19+N.A20+N.G20+N.T20"
## No shape parameters included in fit.
## An object of class 'model'
## 
## Slot "name":  HM-Exd-Ubx4a Nucleotides, no-symmetry 
## Slot "varRegLen":  16 
## Slot "leftFixedSeq":  GTTCAGAGTTCTACAGTCCGACGATCTGG 
## Slot "rightFixedSeq":  CCAGCTGTCGTATGCCGTCTTCTGCTTG 
## Slot "leftFixedSeqOverlap":  5 
## Slot "rightFixedSeqOverlap":  5 
## Slot "confidenceLevel":  0.95 
## Slot "minAffinity":  0 
## Slot "missingValueSuppression":  1 
## Slot "minSeedValue":  0.001 
## Slot "seedLen":  12 
## Slot "consensusSeq":  [ACGT]TGA[CT][ACGT][ACGT]A[CT][ACGT][ACGT][ACGT] 
## Slot "upFootprintExtend":  4 
## Slot "downFootprintExtend":  4 
## Slot "fpLen":  20 
## 
## Fits a model of footprint length 20 for mono-nucleotide features  with 7 view(s) per strand of DNA and 2 round(s) of data (round = 2, 3) without reverse complement symmetry.
## 
## Slot "regressionFormula":  ObservedCount ~ offset(logProb)+Round.2+Round.3+N.A1+N.C1+N.G1+N.T1+N.A2+N.C2+N.G2+N.T2+N.A3+N.C3+N.G3+N.T3+N.A4+N.C4+N.G4+N.T4+N.A5+N.C5+N.G5+N.T5+N.A6+N.C6+N.G6+N.T6+N.A7+N.C7+N.G7+N.T7+N.A8+N.C8+N.G8+N.T8+N.A9+N.C9+N.G9+N.T9+N.A10+N.C10+N.G10+N.T10+N.A11+N.C11+N.G11+N.T11+N.A12+N.C12+N.G12+N.T12+N.A13+N.C13+N.G13+N.T13+N.A14+N.C14+N.G14+N.T14+N.A15+N.C15+N.G15+N.T15+N.A16+N.C16+N.G16+N.T16+N.A17+N.C17+N.G17+N.T17+N.A18+N.C18+N.G18+N.T18+N.A19+N.C19+N.G19+N.T19+N.A20+N.C20+N.G20+N.T20 
## 
## 
## Includes the following feature sub-classes: 
## An object of class 'N'
## Fits 20 nucleotides for a feature model of length 20.
## Nucleotide beta values:
##                1           2           3           4          5          6
## N.A  0.026482206  0.03526757  0.02155358  0.01220695  0.0000000 -0.8692467
## N.C  0.009538382 -0.06575798 -0.12290828 -0.15706184 -0.7892861 -1.6119300
## N.G  0.000000000  0.00000000  0.00000000  0.00000000 -0.2878242 -1.8916495
## N.T -0.044522677 -0.04155334 -0.11642778 -0.07045320 -0.4211544  0.0000000
##              7         8         9        10         11        12
## N.A -0.6406199  0.000000 -1.275110 -1.429245 -1.0150935  0.000000
## N.C -2.7257049 -2.183885 -1.798784 -2.112074 -1.3392859 -2.409205
## N.G  0.0000000 -2.076374 -1.275316 -1.977451 -0.9801776 -2.066354
## N.T -1.1249374 -2.166720  0.000000  0.000000  0.0000000 -2.351845
##            13         14         15         16          17          18
## N.A -1.843629 -0.6285941  0.0000000 -0.4533064 -0.17612721 -0.10762320
## N.C -0.562148 -0.7803892 -0.9016109  0.0000000  0.00000000  0.00000000
## N.G -1.655437  0.0000000 -0.1185666 -0.2165528 -0.24347740 -0.09448531
## N.T  0.000000 -0.1474551 -0.5139788 -0.2557481 -0.07539191  0.06420289
##              19          20
## N.A -0.05098894 -0.01757233
## N.C  0.00000000  0.00000000
## N.G -0.11969939 -0.06719835
## N.T  0.10598625  0.06808155
## 
## Nucleotide beta errors:
##                1            2            3            4            5
## N.A 0.0010935925 0.0009279781 0.0007843717 0.0007429238 0.0000000000
## N.C 0.0010127902 0.0009663038 0.0009863511 0.0009388686 0.0016084920
## N.G 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0006579925
## N.T 0.0008272603 0.0008684330 0.0007928551 0.0007566820 0.0007447276
##               6            7          8           9          10
## N.A 0.001461428 0.0008223838 0.00000000 0.003886868 0.004389409
## N.C 0.008019211 0.1078828928 0.02325545 0.012725810 0.026792553
## N.G 0.012601786 0.0000000000 0.01679550 0.003593650 0.021877729
## N.T 0.000000000 0.0018248568 0.01687581 0.000000000 0.000000000
##              11         12          13           14           15
## N.A 0.002080641 0.00000000 0.012782153 0.0011119417 0.0000000000
## N.C 0.009123107 0.04950934 0.001116799 0.0017822987 0.0021488611
## N.G 0.002181160 0.01833106 0.009781580 0.0000000000 0.0005604796
## N.T 0.000000000 0.03707370 0.000000000 0.0005433043 0.0008703847
##               16           17           18           19          20
## N.A 0.0009931400 0.0008458528 0.0008982906 0.0010072127 0.000801769
## N.C 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.000000000
## N.G 0.0007375898 0.0009641581 0.0010228836 0.0010114523 0.001098073
## N.T 0.0007011484 0.0007380189 0.0008195591 0.0009526098 0.001119095
## 
## 
## An object of class 'Intercept'
## Fits intercept(s) for 2 round(s) (round = 2, 3).
## Intercept beta values:
## Round.2:
## [1] 25.24724
## 
## Round.3:
## [1] 26.17581
## 
## Intercept beta errors:
## Round.2:
## [1] 0.004062965
## 
## Round.3:
## [1] 0.003644921
## 
## 
## 
## An object of class 'Shape'
## Fits 0 shape coefficients for 0 kinds of shape parameter(s) (shape = ) for a feature model of length 20.
## [1] "Number of Observations in Design Matrix: 834273"
## No shape parameters included in fit.
## [1] "Stability Reached after 5 iterations."
ModelTest <- finalizeFeatureBetas(ModelTest)

pM <- plot(ModelTest, plotTitle = "HM-Ubx4a-Exd R2+R3 Nucleotide Fit", Nplot.ddG = TRUE, verticalPlots = TRUE)
ggplot2::ggsave(pM, file = paste(selexDir, saveDir, "/modelPlot.pdf", sep = ""), height = vPheight, width = 6)

save(ModelTest, file = paste(selexDir, saveDir, "/model.RData",sep = ""))
saveRDS(ModelTest, file = paste(selexDir, saveDir, "/model.rds",sep = ""))

some text