Sub Classify()
Dim rngCell As Range
Dim wsLookUp As Worksheet
' Step 1 Reformat annovar
Range("AK1:BB1").Value = Array("Index", "Deleted", "Gene", "mRNA", "Deleted", "Deleted", "Coverage", _
"Score", "A(#F,#R)", "C(#F,#R)", "G(#F,#R)", "T(#F,#R)", "Ins(#F,#R)", _
"Del(#F,#R)", "SNP", "Mutation", "Frequency", "AminoAcid")
Range("AL:AL, AO:AP").EntireColumn.Delete
Range("AK:AY").Copy
Range("A1").Insert
Range("AP:BN").EntireColumn.Delete
Range("AP1:AW1").Value = Array("Homopolymer", "Splice", "Pseudogene", "Classification", "HGMD", _
"Disease", "References", "Sanger")
Columns(3).Insert xlRight
Range("C1").Value = "Inheritance"
Range("1:3").Insert xlShiftDown
With Range("A1:F1")
.Value = Array("Case", "Last Name", "First Name", "Medical Record", "Gender", "Panel", "")
.Resize(2).Interior.ColorIndex = 6
End With
' Step 2 Select Patient
Application.ScreenUpdating = False
With ActiveSheet
lastrow = Cells(.Rows.Count, "CA").End(xlUp).Row
With Selection.Validation
End With
With .Range("A2").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$CA$5:$CA$" & lastrow
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End With
Application.ScreenUpdating = True
' Step 3 Add additional selection information
Dim LastRowNo As Long
LastRowNo = Cells(Rows.Count, "CA").End(xlUp).Row
Worksheets("annovar").Range("B2").Formula = "=IFERROR(VLookup(A2,CA5:CB" & LastRowNo & ",2,0),"""")"
Worksheets("annovar").Range("C2").Formula = "=IFERROR(VLookup(A2,CA5:CC" & LastRowNo & ",3,0),"""")"
Worksheets("annovar").Range("D2").Formula = "=IFERROR(VLookup(A2,CA5:CD" & LastRowNo & ",4,0),"""")"
Worksheets("annovar").Range("E2").Formula = "=IFERROR(VLookup(A2,CA5:CE" & LastRowNo & ",5,0),"""")"
Worksheets("annovar").Range("F2").Formula = "=IFERROR(VLookup(A2,CA5:CF" & LastRowNo & ",6,0),"""")"
' Step 4 Add Inheritance
Set wsLookUp = Sheets("panel")
With Sheets("annovar")
For Each rngCell In .Range("B5", .Range("B" & Rows.Count).End(xlUp))
If WorksheetFunction.CountIf(wsLookUp.Range("G:G"), rngCell.Value) > 0 Then
rngCell.Offset(0, 1).Value = WorksheetFunction.VLookup(rngCell.Value, wsLookUp.Range("G:H"), 2, 0)
Else
rngCell.Offset(0, 1).Value = "Item not found"
End If
Next rngCell
End With
Set wsLookUp = Nothing
End Sub
Calculations VBA:
Sub Calculations()
' Step 5 Add Panel Homopolymer
Dim l As Long
Const myEpilepsy As String = "=IF(SUMPRODUCT(--(Panel!$B$2:$B$6713=$Q$5),--(Panel!$C$2:$C$6713<=$R$5),--(Panel!$D$2:$D$6713>$R$5)),VLOOKUP($R$5,Panel!$C$2:$E$6713,3,1),""No"")"
Const myMarfan As String = "=IF(SUMPRODUCT(--(Panel!$B$25610:$B$29333=$Q$5),--(Panel!$C$25610:$C$29333<=$R$5),--(Panel!$D$25610:$D$29333>$R$5)),VLOOKUP($R$5,Panel!$C$25610:$E$29333,3,1),""No"")"
With Sheets("annovar")
l = .Range("AQ" & .Rows.Count).End(xlUp).Row
If Worksheets("Panel").Range("F2") = "Comprehensive Epilepsy" Then
.Range("AQ5").Formula = myEpilepsy
.Range("AQ5:AQ & l").FillDown
With Sheets("annovar")
l = .Range("AQ" & .Rows.Count).End(xlUp).Row
If Worksheets("Panel").Range("F2") = "Marfan Disorder" Then
.Range("AQ5").Formula = myEpilepsy
.Range("AQ5:AQ & l").FillDown
End With
End Sub
Bookmarks