/// <summary> /// Build cel count and chip type summary file /// </summary> public void BuildChipTypeTable(string tableFileName, string summaryFileName) { if (!FileUtils.IsAbsolutePath(tableFileName)) { tableFileName = Path.Combine(DataDir, tableFileName); } if (!FileUtils.IsAbsolutePath(summaryFileName)) { summaryFileName = Path.Combine(DataDir, summaryFileName); } var dic = CelFile.GetChipTypes(this.rExecute, DataDir, true, tableFileName); using (StreamWriter sw = new StreamWriter(summaryFileName)) { sw.WriteLine("Dataset\tChiptype\tSample"); var dsMap = dic.ToGroupDictionary(m => Path.GetFileName(Path.GetDirectoryName(m.Key))); var subdirs = GetDatasetDirectories(); foreach (var subdir in subdirs) { var dsName = Path.GetFileName(subdir); if (dsMap.ContainsKey(dsName)) { var grp = dsMap[dsName].GroupBy(m => m.Value); var bFirst = true; foreach (var g in grp) { var name = bFirst ? new DirectoryInfo(subdir).Name : string.Empty; bFirst = false; sw.WriteLine("{0}\t{1}\t{2}", name, g.Key, g.Count()); } } } } }
/// <summary> /// Normalization cel files and return the file contains all cel file names /// </summary> /// <param name="root"></param> /// <param name="outputFile"></param> /// <returns></returns> public string Normalization(string root, string outputFile) { var cels = CelFile.GetCelFiles(root); if (cels.Count == 0) { Progress.SetMessage("No cel file found in directory " + DataDir); return(string.Empty); } var inputFile = Path.Combine(root, "celfiles.tsv"); using (var sw = new StreamWriter(inputFile)) { foreach (var cel in cels) { sw.WriteLine(FileUtils.ToLinuxFormat(cel)); } } var roptions = new RTemplateProcessorOptions(); roptions.RExecute = rExecute; roptions.InputFile = inputFile; roptions.OutputFile = inputFile; roptions.NoResultFile = true; roptions.RTemplate = FileUtils.GetTemplateDir() + "\\frma.r"; roptions.CreateNoWindow = true; new RTemplateProcessor(roptions) { Progress = this.Progress }.Process(); CelFile.GetChipTypes(this.rExecute, root, true, outputFile); return(outputFile); }