Example #1
0
            /// <summary>
            /// Execute the analysis
            /// </summary>
            /// <param name = "commandArgs"></param>
            override public void Execute(Args commandArgs)
            {
                Console.WriteLine(commandArgs.StringEnumArgs[Arguments.Tissue]);

                var         nullMapBuilder = new NullMapBuilder(commandArgs.StringEnumArgs[Arguments.Config]);
                IMapBuilder builder        = IUnknown.QueryInterface <IMapBuilder>(nullMapBuilder);

                if (commandArgs.StringEnumArgs.ContainsKey(Arguments.LocusFileName))
                {
                    builder.LocusFileName = commandArgs.StringEnumArgs[Arguments.LocusFileName];
                }

                if (commandArgs.StringEnumArgs.ContainsKey(Arguments.MapFileName))
                {
                    builder.MapFileName    = commandArgs.StringEnumArgs[Arguments.MapFileName];
                    nullMapBuilder.GeneMap = commandArgs.Flags.Contains(Arguments.GeneMap.ToString());
                }

                builder.OutDir = commandArgs.StringEnumArgs.ContainsKey(Arguments.OutDir) ?
                                 commandArgs.StringEnumArgs[Arguments.OutDir] :
                                 builder.OutDir = ".";

                builder.Tissue           = commandArgs.StringEnumArgs[Arguments.Tissue];
                builder.RnaSource        = commandArgs.StringEnumArgs[Arguments.RnaSource];
                builder.LocusFilterRange = commandArgs.IntArgs.ContainsKey(Arguments.RemoveGeneBodyTranscripts.ToString()) ?
                                           commandArgs.IntArgs[Arguments.RemoveGeneBodyTranscripts.ToString()] :
                                           0;

                if (commandArgs.StringEnumArgs.ContainsKey(Arguments.TissueSources))
                {
                    builder.TissueSources = commandArgs.StringEnumArgs[Arguments.TissueSources].Split('\t');
                }

                Stage stage = (Stage)Enum.Parse(typeof(Stage), commandArgs.StringEnumArgs[Arguments.Stage]);

                switch (stage)
                {
                case Stage.Preprocess:
                    builder.PreprocessExpression();
                    break;

                case Stage.BuildMap:
                    builder.BuildMap();
                    break;

                case Stage.RunPipeline:
                    builder.PreprocessExpression();
                    builder.BuildMap();
                    break;

                case Stage.FilterMap:
                    nullMapBuilder.FilterMap((MapLinkFilter.LinkType)Enum.Parse(typeof(MapLinkFilter.LinkType), commandArgs.StringEnumArgs[Arguments.MapType]));
                    break;

                default:
                    throw new Exception("Invalid stage argument: " + commandArgs.StringEnumArgs[Arguments.Stage] + "\nValid values: Preprocess, BuildMap");
                }
            }
            /// <summary>
            /// Execute the analysis for which this class is the factor with the given command line arguments.
            /// </summary>
            /// <param name="commandArgs">Command arguments.</param>
            public override void Execute(Args commandArgs)
            {
                IMapBuilder builder = IUnknown.QueryInterface <IMapBuilder>(new CorrelationMapBuilder(
                                                                                commandArgs.StringEnumArgs[Arguments.Config],
                                                                                commandArgs.StringEnumArgs.GetOptional(Arguments.OmittedTissues)));

                this.ReflectStringArgs(builder, new Arguments[]
                {
                    Arguments.Tissue,
                    Arguments.HistoneName,
                    Arguments.RnaSource,
                });

                this.ReflectOptionalStringArgs(builder, new Arguments[]
                {
                    Arguments.LocusFileName,
                    Arguments.MapFileName,
                });

                this.ReflectOptionalString(builder, Arguments.OutDir, ".");

                this.ReflectFlag(builder, Arguments.UseGenes);
                this.ReflectOptionalInt(builder, Arguments.LocusFilterRange, 0);

                Stage stage = (Stage)Enum.Parse(typeof(Stage), commandArgs.StringEnumArgs[Arguments.Stage]);

                switch (stage)
                {
                case Stage.Preprocess:
                    builder.PreprocessExpression();
                    break;

                case Stage.BuildMap:
                    builder.BuildMap();
                    break;

                case Stage.RunPipeline:
                    builder.PreprocessExpression();
                    builder.BuildMap();
                    break;

                default:
                    throw new Exception("Invalid stage argument: " + commandArgs.StringArgs["Stage"] + "\nValid values: Preprocess, BuildMap");
                }
            }
Example #3
0
        /// <summary>
        /// Factory method for implementations of this interface
        /// </summary>
        /// <returns>The expression data.</returns>
        /// <param name="filename">Filename.</param>
        /// <param name="rnaType">Rna type.</param>
        /// <param name="filetype">Filetype.</param>
        /// <param name="annotation">Annotation.</param>
        public static IExpressionData LoadExpressionData(string filename, string rnaType, string filetype, IAnnotation annotation)
        {
            Console.WriteLine("\tLoading expression file " + filename + " ... ");
            IExpressionData data = null;

            if (filetype == "gtf" || filetype == ".gtf")
            {
                data = IUnknown.QueryInterface <IExpressionData>(new GtfExpressionFile(GtfExpressionFile.ExpressionTypeFromString(rnaType), filename, annotation));
            }
            else
            {
                data = IUnknown.QueryInterface <IExpressionData>(new BedExpressionFile(filename, BedFile.BedExpression, annotation));
            }

            Console.WriteLine("\ttranscript count: " + data.Transcripts.Count);
            Console.WriteLine("\tgene count: " + data.Genes.Count);

            return(data);
        }
Example #4
0
        /// <summary>
        /// Convert the map to genes.
        /// </summary>
        public void Convert()
        {
            MapLinkFilter filter = new MapLinkFilter
            {
                MaximumLinkLength   = this.MaxRange,
                ConfidenceThreshold = this.PvalueThreshold,
                LinkTypeFilter      = MapLinkFilter.LinkType.Any,
            };

            TssRegulatoryMap map = TssRegulatoryMap.LoadMap(this.MapFileName, filter);

            var expression = new GtfExpressionFile(
                GtfExpressionFile.ExpressionTypeFromString(this.RnaSource),
                this.AnnotationFileName);

            var geneMap = map.ConvertToGenes(IUnknown.QueryInterface <IExpressionData>(expression));

            foreach (var link in geneMap.Links)
            {
                var geneLocation = expression.Transcripts[link.TranscriptName];

                string[] lineData = new string[]
                {
                    geneLocation.Chromosome,
                    geneLocation.Start.ToString(),
                    geneLocation.End.ToString(),
                    link.GeneName,
                    "NA",
                    geneLocation.Strand,
                    link.LocusName,
                    link.Correlation.ToString(),
                    link.ConfidenceScore.ToString(),
                    link.LinkLength.ToString(),
                    this.HistoneName,
                    link.TranscriptName,
                };

                Console.WriteLine(string.Join("\t", lineData));
            }
        }