annotate baseline/Baseline_Main.r @ 66:43a1aa648537 draft

Uploaded
author davidvanzessen
date Thu, 07 Dec 2017 03:44:38 -0500
parents c33d93683a09
children ba33b94637ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
1 #########################################################################################
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
2 # License Agreement
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
3 #
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
4 # THIS WORK IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
5 # ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
6 # APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
7 # OR COPYRIGHT LAW IS PROHIBITED.
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
8 #
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
9 # BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
10 # BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
11 # TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
12 # CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
13 #
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
14 # BASELIne: Bayesian Estimation of Antigen-Driven Selection in Immunoglobulin Sequences
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
15 # Coded by: Mohamed Uduman & Gur Yaari
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
16 # Copyright 2012 Kleinstein Lab
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
17 # Version: 1.3 (01/23/2014)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
18 #########################################################################################
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
19
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
20 op <- options();
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
21 options(showWarnCalls=FALSE, showErrorCalls=FALSE, warn=-1)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
22 library('seqinr')
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
23 if( F & Sys.info()[1]=="Linux"){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
24 library("multicore")
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
25 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
26
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
27 # Load functions and initialize global variables
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
28 source("Baseline_Functions.r")
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
29
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
30 # Initialize parameters with user provided arguments
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
31 arg <- commandArgs(TRUE)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
32 #arg = c(2,1,5,5,0,1,"1:26:38:55:65:104:116", "test.fasta","","sample")
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
33 #arg = c(1,1,5,5,0,1,"1:38:55:65:104:116:200", "test.fasta","","sample")
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
34 #arg = c(1,1,5,5,1,1,"1:26:38:55:65:104:116", "/home/mu37/Wu/Wu_Cloned_gapped_sequences_D-masked.fasta","/home/mu37/Wu/","Wu")
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
35 testID <- as.numeric(arg[1]) # 1 = Focused, 2 = Local
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
36 species <- as.numeric(arg[2]) # 1 = Human. 2 = Mouse
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
37 substitutionModel <- as.numeric(arg[3]) # 0 = Uniform substitution, 1 = Smith DS et al. 1996, 5 = FiveS
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
38 mutabilityModel <- as.numeric(arg[4]) # 0 = Uniform mutablity, 1 = Tri-nucleotide (Shapiro GS et al. 2002) , 5 = FiveS
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
39 clonal <- as.numeric(arg[5]) # 0 = Independent sequences, 1 = Clonally related, 2 = Clonally related & only non-terminal mutations
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
40 fixIndels <- as.numeric(arg[6]) # 0 = Do nothing, 1 = Try and fix Indels
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
41 region <- as.numeric(strsplit(arg[7],":")[[1]]) # StartPos:LastNucleotideF1:C1:F2:C2:F3:C3
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
42 inputFilePath <- arg[8] # Full path to input file
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
43 outputPath <- arg[9] # Full path to location of output files
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
44 outputID <- arg[10] # ID for session output
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
45
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
46
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
47 if(testID==5){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
48 traitChangeModel <- 1
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
49 if( !is.na(any(arg[11])) ) traitChangeModel <- as.numeric(arg[11]) # 1 <- Chothia 1998
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
50 initializeTraitChange(traitChangeModel)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
51 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
52
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
53 # Initialize other parameters/variables
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
54
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
55 # Initialzie the codon table ( definitions of R/S )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
56 computeCodonTable(testID)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
57
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
58 # Initialize
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
59 # Test Name
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
60 testName<-"Focused"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
61 if(testID==2) testName<-"Local"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
62 if(testID==3) testName<-"Imbalanced"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
63 if(testID==4) testName<-"ImbalancedSilent"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
64
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
65 # Indel placeholders initialization
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
66 indelPos <- NULL
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
67 delPos <- NULL
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
68 insPos <- NULL
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
69
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
70 # Initialize in Tranistion & Mutability matrixes
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
71 substitution <- initializeSubstitutionMatrix(substitutionModel,species)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
72 mutability <- initializeMutabilityMatrix(mutabilityModel,species)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
73
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
74 # FWR/CDR boundaries
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
75 flagTrim <- F
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
76 if( is.na(region[7])){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
77 flagTrim <- T
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
78 region[7]<-region[6]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
79 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
80 readStart = min(region,na.rm=T)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
81 readEnd = max(region,na.rm=T)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
82 if(readStart>1){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
83 region = region - (readStart - 1)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
84 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
85 region_Nuc = c( (region[1]*3-2) , (region[2:7]*3) )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
86 region_Cod = region
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
87
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
88 readStart = (readStart*3)-2
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
89 readEnd = (readEnd*3)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
90
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
91 FWR_Nuc <- c( rep(TRUE,(region_Nuc[2])),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
92 rep(FALSE,(region_Nuc[3]-region_Nuc[2])),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
93 rep(TRUE,(region_Nuc[4]-region_Nuc[3])),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
94 rep(FALSE,(region_Nuc[5]-region_Nuc[4])),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
95 rep(TRUE,(region_Nuc[6]-region_Nuc[5])),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
96 rep(FALSE,(region_Nuc[7]-region_Nuc[6]))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
97 )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
98 CDR_Nuc <- (1-FWR_Nuc)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
99 CDR_Nuc <- as.logical(CDR_Nuc)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
100 FWR_Nuc_Mat <- matrix( rep(FWR_Nuc,4), ncol=length(FWR_Nuc), nrow=4, byrow=T)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
101 CDR_Nuc_Mat <- matrix( rep(CDR_Nuc,4), ncol=length(CDR_Nuc), nrow=4, byrow=T)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
102
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
103 FWR_Codon <- c( rep(TRUE,(region[2])),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
104 rep(FALSE,(region[3]-region[2])),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
105 rep(TRUE,(region[4]-region[3])),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
106 rep(FALSE,(region[5]-region[4])),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
107 rep(TRUE,(region[6]-region[5])),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
108 rep(FALSE,(region[7]-region[6]))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
109 )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
110 CDR_Codon <- (1-FWR_Codon)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
111 CDR_Codon <- as.logical(CDR_Codon)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
112
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
113
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
114 # Read input FASTA file
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
115 tryCatch(
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
116 inputFASTA <- baseline.read.fasta(inputFilePath, seqtype="DNA",as.string=T,set.attributes=F,forceDNAtolower=F)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
117 , error = function(ex){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
118 cat("Error|Error reading input. Please enter or upload a valid FASTA file.\n")
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
119 q()
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
120 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
121 )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
122
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
123 if (length(inputFASTA)==1) {
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
124 cat("Error|Error reading input. Please enter or upload a valid FASTA file.\n")
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
125 q()
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
126 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
127
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
128 # Process sequence IDs/names
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
129 names(inputFASTA) <- sapply(names(inputFASTA),function(x){trim(x)})
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
130
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
131 # Convert non nucleotide characters to N
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
132 inputFASTA[length(inputFASTA)] = gsub("\t","",inputFASTA[length(inputFASTA)])
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
133 inputFASTA <- lapply(inputFASTA,replaceNonFASTAChars)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
134
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
135 # Process the FASTA file and conver to Matrix[inputSequence, germlineSequence]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
136 processedInput <- processInputAdvanced(inputFASTA)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
137 matInput <- processedInput[[1]]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
138 germlines <- processedInput[[2]]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
139 lenGermlines = length(unique(germlines))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
140 groups <- processedInput[[3]]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
141 lenGroups = length(unique(groups))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
142 rm(processedInput)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
143 rm(inputFASTA)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
144
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
145 # # remove clones with less than 2 seqeunces
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
146 # tableGL <- table(germlines)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
147 # singletons <- which(tableGL<8)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
148 # rowsToRemove <- match(singletons,germlines)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
149 # if(any(rowsToRemove)){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
150 # matInput <- matInput[-rowsToRemove,]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
151 # germlines <- germlines[-rowsToRemove]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
152 # groups <- groups[-rowsToRemove]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
153 # }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
154 #
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
155 # # remove unproductive seqs
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
156 # nonFuctionalSeqs <- sapply(rownames(matInput),function(x){any(grep("unproductive",x))})
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
157 # if(any(nonFuctionalSeqs)){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
158 # if(sum(nonFuctionalSeqs)==length(germlines)){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
159 # write.table("Unproductive",file=paste(outputPath,outputID,".txt",sep=""),quote=F,sep="\t",row.names=F,col.names=T)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
160 # q()
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
161 # }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
162 # matInput <- matInput[-which(nonFuctionalSeqs),]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
163 # germlines <- germlines[-which(nonFuctionalSeqs)]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
164 # germlines[1:length(germlines)] <- 1:length(germlines)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
165 # groups <- groups[-which(nonFuctionalSeqs)]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
166 # }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
167 #
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
168 # if(class(matInput)=="character"){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
169 # write.table("All unproductive seqs",file=paste(outputPath,outputID,".txt",sep=""),quote=F,sep="\t",row.names=F,col.names=T)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
170 # q()
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
171 # }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
172 #
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
173 # if(nrow(matInput)<10 | is.null(nrow(matInput))){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
174 # write.table(paste(nrow(matInput), "seqs only",sep=""),file=paste(outputPath,outputID,".txt",sep=""),quote=F,sep="\t",row.names=F,col.names=T)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
175 # q()
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
176 # }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
177
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
178 # replace leading & trailing "-" with "N:
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
179 matInput <- t(apply(matInput,1,replaceLeadingTrailingDashes,readEnd))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
180
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
181 # Trim (nucleotide) input sequences to the last codon
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
182 #matInput[,1] <- apply(matrix(matInput[,1]),1,trimToLastCodon)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
183
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
184 # # Check for Indels
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
185 # if(fixIndels){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
186 # delPos <- fixDeletions(matInput)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
187 # insPos <- fixInsertions(matInput)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
188 # }else{
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
189 # # Check for indels
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
190 # indelPos <- checkForInDels(matInput)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
191 # indelPos <- apply(cbind(indelPos[[1]],indelPos[[2]]),1,function(x){(x[1]==T & x[2]==T)})
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
192 # }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
193
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
194 # If indels are present, remove mutations in the seqeunce & throw warning at end
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
195 #matInput[indelPos,] <- apply(matrix(matInput[indelPos,],nrow=sum(indelPos),ncol=2),1,function(x){x[1]=x[2]; return(x) })
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
196
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
197 colnames(matInput)=c("Input","Germline")
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
198
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
199 # If seqeunces are clonal, create effective sequence for each clone & modify germline/group definitions
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
200 germlinesOriginal = NULL
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
201 if(clonal){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
202 germlinesOriginal <- germlines
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
203 collapseCloneResults <- tapply(1:nrow(matInput),germlines,function(i){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
204 collapseClone(matInput[i,1],matInput[i[1],2],readEnd,nonTerminalOnly=(clonal-1))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
205 })
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
206 matInput = t(sapply(collapseCloneResults,function(x){return(x[[1]])}))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
207 names_groups = tapply(groups,germlines,function(x){names(x[1])})
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
208 groups = tapply(groups,germlines,function(x){array(x[1],dimnames=names(x[1]))})
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
209 names(groups) = names_groups
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
210
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
211 names_germlines = tapply(germlines,germlines,function(x){names(x[1])})
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
212 germlines = tapply( germlines,germlines,function(x){array(x[1],dimnames=names(x[1]))} )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
213 names(germlines) = names_germlines
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
214 matInputErrors = sapply(collapseCloneResults,function(x){return(x[[2]])})
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
215 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
216
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
217
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
218 # Selection Analysis
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
219
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
220
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
221 # if (length(germlines)>sequenceLimit) {
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
222 # # Code to parallelize processing goes here
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
223 # stop( paste("Error: Cannot process more than ", Upper_limit," sequences",sep="") )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
224 # }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
225
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
226 # if (length(germlines)<sequenceLimit) {}
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
227
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
228 # Compute expected mutation frequencies
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
229 matExpected <- getExpectedIndividual(matInput)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
230
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
231 # Count observed number of mutations in the different regions
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
232 mutations <- lapply( 1:nrow(matInput), function(i){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
233 #cat(i,"\n")
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
234 seqI = s2c(matInput[i,1])
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
235 seqG = s2c(matInput[i,2])
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
236 matIGL = matrix(c(seqI,seqG),ncol=length(seqI),nrow=2,byrow=T)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
237 retVal <- NA
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
238 tryCatch(
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
239 retVal <- analyzeMutations2NucUri(matIGL)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
240 , error = function(ex){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
241 retVal <- NA
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
242 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
243 )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
244
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
245
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
246 return( retVal )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
247 })
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
248
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
249 matObserved <- t(sapply( mutations, processNucMutations2 ))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
250 numberOfSeqsWithMutations <- numberOfSeqsWithMutations(matObserved, testID)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
251
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
252 #if(sum(numberOfSeqsWithMutations)==0){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
253 # write.table("No mutated sequences",file=paste(outputPath,outputID,".txt",sep=""),quote=F,sep="\t",row.names=F,col.names=T)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
254 # q()
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
255 #}
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
256
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
257 matMutationInfo <- cbind(matObserved,matExpected)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
258 rm(matObserved,matExpected)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
259
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
260
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
261 #Bayesian PDFs
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
262 bayes_pdf = computeBayesianScore(matMutationInfo, test=testName, max_sigma=20,length_sigma=4001)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
263 bayesPDF_cdr = bayes_pdf[[1]]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
264 bayesPDF_fwr = bayes_pdf[[2]]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
265 rm(bayes_pdf)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
266
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
267 bayesPDF_germlines_cdr = tapply(bayesPDF_cdr,germlines,function(x) groupPosteriors(x,length_sigma=4001))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
268 bayesPDF_germlines_fwr = tapply(bayesPDF_fwr,germlines,function(x) groupPosteriors(x,length_sigma=4001))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
269
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
270 bayesPDF_groups_cdr = tapply(bayesPDF_cdr,groups,function(x) groupPosteriors(x,length_sigma=4001))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
271 bayesPDF_groups_fwr = tapply(bayesPDF_fwr,groups,function(x) groupPosteriors(x,length_sigma=4001))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
272
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
273 if(lenGroups>1){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
274 groups <- c(groups,lenGroups+1)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
275 names(groups)[length(groups)] = "All sequences combined"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
276 bayesPDF_groups_cdr[[lenGroups+1]] = groupPosteriors(bayesPDF_groups_cdr,length_sigma=4001)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
277 bayesPDF_groups_fwr[[lenGroups+1]] = groupPosteriors(bayesPDF_groups_fwr,length_sigma=4001)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
278 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
279
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
280 #Bayesian Outputs
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
281 bayes_cdr = t(sapply(bayesPDF_cdr,calcBayesOutputInfo))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
282 bayes_fwr = t(sapply(bayesPDF_fwr,calcBayesOutputInfo))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
283 bayes_germlines_cdr = t(sapply(bayesPDF_germlines_cdr,calcBayesOutputInfo))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
284 bayes_germlines_fwr = t(sapply(bayesPDF_germlines_fwr,calcBayesOutputInfo))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
285 bayes_groups_cdr = t(sapply(bayesPDF_groups_cdr,calcBayesOutputInfo))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
286 bayes_groups_fwr = t(sapply(bayesPDF_groups_fwr,calcBayesOutputInfo))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
287
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
288 #P-values
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
289 simgaP_cdr = sapply(bayesPDF_cdr,computeSigmaP)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
290 simgaP_fwr = sapply(bayesPDF_fwr,computeSigmaP)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
291
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
292 simgaP_germlines_cdr = sapply(bayesPDF_germlines_cdr,computeSigmaP)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
293 simgaP_germlines_fwr = sapply(bayesPDF_germlines_fwr,computeSigmaP)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
294
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
295 simgaP_groups_cdr = sapply(bayesPDF_groups_cdr,computeSigmaP)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
296 simgaP_groups_fwr = sapply(bayesPDF_groups_fwr,computeSigmaP)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
297
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
298
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
299 #Format output
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
300
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
301 # Round expected mutation frequencies to 3 decimal places
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
302 matMutationInfo[germlinesOriginal[indelPos],] = NA
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
303 if(nrow(matMutationInfo)==1){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
304 matMutationInfo[5:8] = round(matMutationInfo[,5:8]/sum(matMutationInfo[,5:8],na.rm=T),3)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
305 }else{
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
306 matMutationInfo[,5:8] = t(round(apply(matMutationInfo[,5:8],1,function(x){ return(x/sum(x,na.rm=T)) }),3))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
307 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
308
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
309 listPDFs = list()
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
310 nRows = length(unique(groups)) + length(unique(germlines)) + length(groups)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
311
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
312 matOutput = matrix(NA,ncol=18,nrow=nRows)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
313 rowNumb = 1
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
314 for(G in unique(groups)){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
315 #print(G)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
316 matOutput[rowNumb,c(1,2,11:18)] = c("Group",names(groups)[groups==G][1],bayes_groups_cdr[G,],bayes_groups_fwr[G,],simgaP_groups_cdr[G],simgaP_groups_fwr[G])
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
317 listPDFs[[rowNumb]] = list("CDR"=bayesPDF_groups_cdr[[G]],"FWR"=bayesPDF_groups_fwr[[G]])
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
318 names(listPDFs)[rowNumb] = names(groups[groups==paste(G)])[1]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
319 #if(names(groups)[which(groups==G)[1]]!="All sequences combined"){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
320 gs = unique(germlines[groups==G])
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
321 rowNumb = rowNumb+1
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
322 if( !is.na(gs) ){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
323 for( g in gs ){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
324 matOutput[rowNumb,c(1,2,11:18)] = c("Germline",names(germlines)[germlines==g][1],bayes_germlines_cdr[g,],bayes_germlines_fwr[g,],simgaP_germlines_cdr[g],simgaP_germlines_fwr[g])
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
325 listPDFs[[rowNumb]] = list("CDR"=bayesPDF_germlines_cdr[[g]],"FWR"=bayesPDF_germlines_fwr[[g]])
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
326 names(listPDFs)[rowNumb] = names(germlines[germlines==paste(g)])[1]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
327 rowNumb = rowNumb+1
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
328 indexesOfInterest = which(germlines==g)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
329 numbSeqsOfInterest = length(indexesOfInterest)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
330 rowNumb = seq(rowNumb,rowNumb+(numbSeqsOfInterest-1))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
331 matOutput[rowNumb,] = matrix( c( rep("Sequence",numbSeqsOfInterest),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
332 rownames(matInput)[indexesOfInterest],
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
333 c(matMutationInfo[indexesOfInterest,1:4]),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
334 c(matMutationInfo[indexesOfInterest,5:8]),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
335 c(bayes_cdr[indexesOfInterest,]),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
336 c(bayes_fwr[indexesOfInterest,]),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
337 c(simgaP_cdr[indexesOfInterest]),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
338 c(simgaP_fwr[indexesOfInterest])
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
339 ), ncol=18, nrow=numbSeqsOfInterest,byrow=F)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
340 increment=0
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
341 for( ioi in indexesOfInterest){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
342 listPDFs[[min(rowNumb)+increment]] = list("CDR"=bayesPDF_cdr[[ioi]] , "FWR"=bayesPDF_fwr[[ioi]])
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
343 names(listPDFs)[min(rowNumb)+increment] = rownames(matInput)[ioi]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
344 increment = increment + 1
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
345 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
346 rowNumb=max(rowNumb)+1
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
347
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
348 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
349 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
350 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
351 colsToFormat = 11:18
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
352 matOutput[,colsToFormat] = formatC( matrix(as.numeric(matOutput[,colsToFormat]), nrow=nrow(matOutput), ncol=length(colsToFormat)) , digits=3)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
353 matOutput[matOutput== " NaN"] = NA
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
354
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
355
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
356
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
357 colnames(matOutput) = c("Type", "ID", "Observed_CDR_R", "Observed_CDR_S", "Observed_FWR_R", "Observed_FWR_S",
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
358 "Expected_CDR_R", "Expected_CDR_S", "Expected_FWR_R", "Expected_FWR_S",
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
359 paste( rep(testName,6), rep(c("Sigma","CIlower","CIupper"),2),rep(c("CDR","FWR"),each=3), sep="_"),
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
360 paste( rep(testName,2), rep("P",2),c("CDR","FWR"), sep="_")
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
361 )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
362 fileName = paste(outputPath,outputID,".txt",sep="")
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
363 write.table(matOutput,file=fileName,quote=F,sep="\t",row.names=T,col.names=NA)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
364 fileName = paste(outputPath,outputID,".RData",sep="")
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
365 save(listPDFs,file=fileName)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
366
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
367 indelWarning = FALSE
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
368 if(sum(indelPos)>0){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
369 indelWarning = "<P>Warning: The following sequences have either gaps and/or deletions, and have been ommited from the analysis.";
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
370 indelWarning = paste( indelWarning , "<UL>", sep="" )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
371 for(indels in names(indelPos)[indelPos]){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
372 indelWarning = paste( indelWarning , "<LI>", indels, "</LI>", sep="" )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
373 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
374 indelWarning = paste( indelWarning , "</UL></P>", sep="" )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
375 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
376
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
377 cloneWarning = FALSE
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
378 if(clonal==1){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
379 if(sum(matInputErrors)>0){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
380 cloneWarning = "<P>Warning: The following clones have sequences of unequal length.";
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
381 cloneWarning = paste( cloneWarning , "<UL>", sep="" )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
382 for(clone in names(matInputErrors)[matInputErrors]){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
383 cloneWarning = paste( cloneWarning , "<LI>", names(germlines)[as.numeric(clone)], "</LI>", sep="" )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
384 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
385 cloneWarning = paste( cloneWarning , "</UL></P>", sep="" )
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
386 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
387 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
388 cat(paste("Success",outputID,indelWarning,cloneWarning,sep="|"))