public VennDiagramData CenterVennDiagramData() { // Shift the circles to be centered about zero VennDiagramData v = new VennDiagramData(this); v.Center(); return(v); }
//************************************************************************* // Method: CreateVennDiagramNodeXLFile() // /// <summary> /// Demonstrates how the NodeXL template can be used to display a Venn /// diagram. /// </summary> /// /// <remarks> /// Requirements: /// /// <para> /// Excel 2007. /// </para> /// /// <para> /// The NodeXL Excel 2007 Template must be installed, and the version must /// be 1.0.1.105 or above. This is available at /// http://nodexl.codeplex.com/Release/ProjectReleases.aspx. /// </para> /// /// <para> /// NodeXL, Graph, Layout must be set to Polar Absolute in the Excel /// ribbon. NodeXL provided a new sheet to drive this during the /// period of initial visibility. You must have everything setup /// properly before setting the worksheet to visible. /// </para> /// /// </remarks> //************************************************************************* public static void CreateVennDiagramNodeXLFile ( String filename, VennDiagramData vdd ) { // Create a workbook instance of the NodeXL template // Populate it iwht the Venn. // Dev10 errors on the original (next) line. replaced with the line below. //Application oApplication = new ApplicationClass(); Application oApplication = (Application)Activator.CreateInstance(Type.GetTypeFromProgID("Excel.Application")); Workbook oWorkbook = CreateNodeXLVennDiagramWorkbook(oApplication, vdd); oWorkbook.SaveAs(filename, XlFileFormat.xlWorkbookDefault, null, null, false, false, XlSaveAsAccessMode.xlExclusive, null, true, null, null, null); oApplication.Quit(); }
public VennDiagramData(VennDiagramData vdd) { vennType = vdd.vennType; RegionA = vdd.RegionA; RegionB = vdd.RegionB; RegionC = vdd.RegionC; RegionAB = vdd.RegionAB; RegionAC = vdd.RegionAC; RegionBC = vdd.RegionBC; RegionABC = vdd.RegionABC; DistanceAB = vdd.DistanceAB; DistanceAC = vdd.DistanceAC; DistanceBC = vdd.DistanceBC; CircleA = new VennCircle(vdd.CircleA); CircleB = new VennCircle(vdd.CircleB); if (vennType == VennTypes.ThreeCircle) { CircleC = new VennCircle(vdd.CircleC); } fScaled = vdd.fScaled; }
CreateNodeXLVennDiagramWorkbook ( Application oApplication, VennDiagramData vdd ) { String sTemplatePath; if (!TryGetTemplatePath(oApplication, out sTemplatePath)) { OnUnexpectedCondition(Properties.Resources.NodeXLNotInstalled); } Workbook oWorkbook = oApplication.Workbooks.Add(sTemplatePath); // Tell NodeXL to start up in the "Polar Absolute" mode // and auto display on startup ListObject oPerWorkbookSettingsTable; if (!ExcelUtil.TryGetTable(oWorkbook, "Misc", "PerWorkbookSettings", out oPerWorkbookSettingsTable)) { OnUnexpectedCondition(Properties.Resources.PerWorkbookTableMissing); } SetLayoutAndReadWorkbook(oPerWorkbookSettingsTable); // The workbook consists of multiple worksheets, but for a Venn diagram // with no edges, only the vertex worksheet needs to be filled in. // Get the vertex table on the vertex worksheet. ListObject oVertexTable; if (!ExcelUtil.TryGetTable(oWorkbook, "Vertices", "Vertices", out oVertexTable)) { OnUnexpectedCondition(Properties.Resources.VertexTableMissing); } // make Vertex tab active Worksheet oWorksheet; ExcelUtil.TryGetWorksheet(oWorkbook, "Vertices", out oWorksheet); // See this posting for an explanation of the strange cast: // http://blogs.officezealot.com/maarten/archive/2006/01/02/8918.aspx ((_Worksheet)oWorksheet).Activate(); AddVennVertices(oVertexTable, vdd); //AddAlternativeVertexLabels(oVertexTable); // when we need to implement out a different labeling scheme... return oWorkbook; }
AddVennVertices ( ListObject vertexTable, VennDiagramData vddOriginal ) { Debug.Assert(vertexTable != null); VennDiagramData vdd = vddOriginal.CenterVennDiagramData(); vdd.ScaleTo(150); // Add two or three vertices. Name them via the Vertex column. AddVennVertex(vertexTable, vdd.CircleA, 0, "A", "Red"); AddVennVertex(vertexTable, vdd.CircleB, 1, "B", "Green"); if (vdd.vennType == VennDiagramData.VennTypes.ThreeCircle) { AddVennVertex(vertexTable, vdd.CircleC, 2, "C", "Blue"); } }
CreateNodeXLVennDiagramWorkbookFromSequenceRangeGroupings ( Microsoft.Office.Interop.Excel.Application oApplication, SequenceRangeGrouping srgA, SequenceRangeGrouping srgB, SequenceRangeGrouping srgC ) { SequenceRangeGrouping srgOnly_A, srgOnly_B, srgOnly_C, srgOnly_AB, srgOnly_AC, srgOnly_BC, srgOnly_ABC; CreateSequenceRangeGroupingsForVennDiagram(srgA , srgB , srgC , out srgOnly_A , out srgOnly_B , out srgOnly_C , out srgOnly_AB , out srgOnly_AC , out srgOnly_BC , out srgOnly_ABC); // generate the intersection Venn metrics SequenceRangeGroupingMetrics srgmOnly_A = new SequenceRangeGroupingMetrics(srgOnly_A); SequenceRangeGroupingMetrics srgmOnly_B = new SequenceRangeGroupingMetrics(srgOnly_B); SequenceRangeGroupingMetrics srgmOnly_C = new SequenceRangeGroupingMetrics(srgOnly_C); SequenceRangeGroupingMetrics srgmOnly_AB = new SequenceRangeGroupingMetrics(srgOnly_AB); SequenceRangeGroupingMetrics srgmOnly_AC = new SequenceRangeGroupingMetrics(srgOnly_AC); SequenceRangeGroupingMetrics srgmOnly_BC = new SequenceRangeGroupingMetrics(srgOnly_BC); SequenceRangeGroupingMetrics srgmOnly_ABC = new SequenceRangeGroupingMetrics(srgOnly_ABC); // create the NodeXL Venn diagram filefile VennDiagramData vdd = new VennDiagramData(srgmOnly_A.bases , srgmOnly_B.bases , srgmOnly_C.bases , srgmOnly_AB.bases , srgmOnly_AC.bases , srgmOnly_BC.bases , srgmOnly_ABC.bases); // To ensure NodeXL displays the diagram, DONOT make the application // visible or update the screen until the parameters are all set up. oApplication.ScreenUpdating = false; Workbook oWorkbook = CreateNodeXLVennDiagramWorkbook(oApplication, vdd); // write source data to workbook DisplaySourceData(srgA, Resources.A, oWorkbook); DisplaySourceData(srgB, Resources.B, oWorkbook); DisplaySourceData(srgC, Resources.C, oWorkbook); // Write overlap data to a sheet Worksheet outputSheet = oWorkbook.Sheets.Add(Type.Missing, oWorkbook.Sheets[oWorkbook.Sheets.Count], 1, XlSheetType.xlWorksheet); outputSheet.Name = Resources.OverlapsSheetName; WriteOverlapData(outputSheet, srgOnly_A, srgOnly_B, srgOnly_C, srgOnly_AB, srgOnly_AC, srgOnly_BC, srgOnly_ABC); oApplication.ScreenUpdating = true; oApplication.Visible = true; return oWorkbook; }
CreateNodeXLVennDiagramWorkbookFromSequenceRangeGroupings ( Microsoft.Office.Interop.Excel.Application oApplication, SequenceRangeGrouping srgA, SequenceRangeGrouping srgB ) { // create the proper sets for VennDiagram SequenceRangeGrouping srgOnly_A, srgOnly_B, srgOnly_AB; CreateSequenceRangeGroupingsForVennDiagram(srgA, srgB, out srgOnly_A, out srgOnly_B, out srgOnly_AB); SequenceRangeGroupingMetrics srgmOnly_A = new SequenceRangeGroupingMetrics(srgOnly_A); SequenceRangeGroupingMetrics srgmOnly_B = new SequenceRangeGroupingMetrics(srgOnly_B); SequenceRangeGroupingMetrics srgmOnly_AB = new SequenceRangeGroupingMetrics(srgOnly_AB); VennDiagramData vdd = new VennDiagramData(srgmOnly_A.bases , srgmOnly_B.bases , srgmOnly_AB.bases); Workbook oWorkbook = CreateNodeXLVennDiagramWorkbook(oApplication, vdd); // write source data to workbook DisplaySourceData(srgA, Resources.A, oWorkbook); DisplaySourceData(srgB, Resources.B, oWorkbook); // Write overlap data to a sheet Worksheet outputSheet = oWorkbook.Sheets.Add(Type.Missing, oWorkbook.Sheets[oWorkbook.Sheets.Count], 1, XlSheetType.xlWorksheet); outputSheet.Name = Resources.OverlapsSheetName; WriteOverlapData(outputSheet, srgOnly_A, srgOnly_B, srgOnly_AB); oApplication.Visible = true; return oWorkbook; }
public VennDiagramData CenterVennDiagramData() { // Shift the circles to be centered about zero VennDiagramData v = new VennDiagramData(this); v.Center(); return v; }
public static void Main(string[] args) { Splash(); arguments = ProcessCommandLineArguments(args); VennDiagramData vdd = new VennDiagramData(arguments.regionArray); if (arguments.polar) { vdd.WritePolarVennDiagramData(); } else { vdd.WriteVennDiagramData(); } if (arguments.xl.Length > 0) { // produce an XL file with the 'right stuff' // Make sure we pass a complete filename path too. string filename = Path.GetFullPath(arguments.xl); Console.WriteLine("Produce Excel VennDiagram file: {0}", filename); VennToNodeXL.CreateVennDiagramNodeXLFile(filename, vdd); } }
public static int Main(string[] args) { try { Splash(); arguments = ProcessCommandLineArguments(args); if (arguments.inputFiles.Count() == 2) { // now read the 2 BED files and do the operation to isolate each set SequenceRangeGrouping srg1 = ReadBedFile(arguments.inputFiles[0]); SequenceRangeGrouping srg2 = ReadBedFile(arguments.inputFiles[1]); SequenceRangeGrouping srgOnly_A, srgOnly_B, srgOnly_AB; VennToNodeXL.CreateSequenceRangeGroupingsForVennDiagram( srg1, srg2, out srgOnly_A, out srgOnly_B, out srgOnly_AB); var srgmOnly_A = new SequenceRangeGroupingMetrics(srgOnly_A); var srgmOnly_B = new SequenceRangeGroupingMetrics(srgOnly_B); var srgmOnly_AB = new SequenceRangeGroupingMetrics(srgOnly_AB); if (createVennToolInputFile) { Console.Error.Write("\nWriting file [{0}]", vennToolInputFileFullPath); var VennOutput = new StreamWriter(vennToolInputFileFullPath); VennOutput.WriteLine("{0} {1} {2}", srgmOnly_A.bases, srgmOnly_B.bases, srgmOnly_AB.bases); VennOutput.Close(); Console.Error.Write(" ... Done."); } if (createExcelWorkbook) { // create the Excel workbook with a NodeXL Venn diagram Console.Error.Write("\nWriting file [{0}]", excelWorkbookFullPath); var vdd = new VennDiagramData(srgmOnly_A.bases, srgmOnly_B.bases, srgmOnly_AB.bases); try { VennToNodeXL.CreateVennDiagramNodeXLFile(excelWorkbookFullPath, vdd); Console.Error.Write(" ... Done.\n"); } catch (Exception e) { Console.Error.Write("Error: Unable to create Excel workbook."); DisplayException(e); Environment.Exit(-1); } } if (verbose) { Console.Error.Write("\nDump Sequence Groupings from two files\n"); SequenceRangeGroupingToString(srgOnly_A, "srgOnly_A"); SequenceRangeGroupingToString(srgOnly_B, "srgOnly_B"); SequenceRangeGroupingToString(srgOnly_AB, "srgOnly_AB"); Console.Error.Write("\nEnd Sequence group from twoe files\n"); } Console.Write("\nOutput basepair count for each set"); Console.Write("\nGroupA,GroupB,GroupAB"); Console.Write("\n{0},{1},{2}\n", srgmOnly_A.bases, srgmOnly_B.bases, srgmOnly_AB.bases); } else if (arguments.inputFiles.Count() == 3) { // TODO: Reduce memory usage by re-using the SRGs after debugging is complete // // now read the 3 BED files and do the operation to isolate each set SequenceRangeGrouping srg1 = ReadBedFile(arguments.inputFiles[0]); SequenceRangeGrouping srg2 = ReadBedFile(arguments.inputFiles[1]); SequenceRangeGrouping srg3 = ReadBedFile(arguments.inputFiles[2]); SequenceRangeGrouping srgOnly_A, srgOnly_B, srgOnly_C, srgOnly_AB, srgOnly_AC, srgOnly_BC, srgOnly_ABC; VennToNodeXL.CreateSequenceRangeGroupingsForVennDiagram( srg1, srg2, srg3, out srgOnly_A, out srgOnly_B, out srgOnly_C, out srgOnly_AB, out srgOnly_AC, out srgOnly_BC, out srgOnly_ABC); /* * We have the set information data for the three files. * Now what? */ // generate the intersection Venn metrics var srgmOnly_A = new SequenceRangeGroupingMetrics(srgOnly_A); var srgmOnly_B = new SequenceRangeGroupingMetrics(srgOnly_B); var srgmOnly_C = new SequenceRangeGroupingMetrics(srgOnly_C); var srgmOnly_AB = new SequenceRangeGroupingMetrics(srgOnly_AB); var srgmOnly_AC = new SequenceRangeGroupingMetrics(srgOnly_AC); var srgmOnly_BC = new SequenceRangeGroupingMetrics(srgOnly_BC); var srgmOnly_ABC = new SequenceRangeGroupingMetrics(srgOnly_ABC); if (createVennToolInputFile) { Console.Error.Write("\nWriting file [{0}]", vennToolInputFileFullPath); var VennOutput = new StreamWriter(vennToolInputFileFullPath); VennOutput.WriteLine( "{0} {1} {2} {3} {4} {5} {6}", srgmOnly_A.bases, srgmOnly_B.bases, srgmOnly_C.bases, srgmOnly_AB.bases, srgmOnly_AC.bases, srgmOnly_BC.bases, srgmOnly_ABC.bases); VennOutput.Close(); Console.Error.Write(" ... Done."); } if (createExcelWorkbook) { // create the NodeXL Venn diagram filefile var vdd = new VennDiagramData( srgmOnly_A.bases, srgmOnly_B.bases, srgmOnly_C.bases, srgmOnly_AB.bases, srgmOnly_AC.bases, srgmOnly_BC.bases, srgmOnly_ABC.bases); // create the Excel workbook with a NodeXL Venn diagram Console.Error.Write("\nWriting file [{0}]", excelWorkbookFullPath); try { VennToNodeXL.CreateVennDiagramNodeXLFile(excelWorkbookFullPath, vdd); Console.Error.Write(" ... Done.\n"); } catch (Exception e) { Console.Error.Write("\nError: Unable to create Excel workbook."); DisplayException(e); Environment.Exit(-1); } } if (verbose) { Console.Error.Write("\nDump Sequence Groupings from three files\n"); SequenceRangeGroupingToString(srgOnly_A, "srgOnly_A"); SequenceRangeGroupingToString(srgOnly_B, "srgOnly_B"); SequenceRangeGroupingToString(srgOnly_C, "srgOnly_C"); SequenceRangeGroupingToString(srgOnly_AB, "srgOnly_AB"); SequenceRangeGroupingToString(srgOnly_AC, "srgOnly_AC"); SequenceRangeGroupingToString(srgOnly_BC, "srgOnly_BC"); SequenceRangeGroupingToString(srgOnly_ABC, "srgOnly_ABC"); Console.Error.Write("\nEnd Sequence group from three files\n"); } Console.Write("\nOutput basepair count for each set"); Console.Write("\nGroupA,GroupB,GroupC,GroupAB,GroupAC,GroupBC,GroupABC"); Console.Write( "\n{0},{1},{2},{3},{4},{5},{6}\n", srgmOnly_A.bases, srgmOnly_B.bases, srgmOnly_C.bases, srgmOnly_AB.bases, srgmOnly_AC.bases, srgmOnly_BC.bases, srgmOnly_ABC.bases); } } catch (Exception ex) { DisplayException(ex); } return 0; }