Exemplo n.º 1
0
        private void frm_BasicOne_BasicOneUpdated(object sender, BasicOneChipEventArgs e)
        {
            //List<mSpotValue> msv = new List<mSpotValue>();

            DataTable dt = new DataTable();

            string mm; //Records.GetInvalidGlobalHandling(e.RecName);

            if (Chips.GetInvalidLocalHandling(e.ChipName) == "No" || Records.GetInvalidGlobalHandling(e.RecName) == "No")
            {
                mm = "No";
            }
            else
            {
                mm = "Yes";
            }


            dt = SubChips.GetSubChipsmCSM(e.RecName, e.ChipName, Records.GetGlobalMeanMethod(e.RecName), mm);
            //msv = SubChips.CalculatemCSM(SubChips.GetSubChipID(e.RecName, e.ChipName, e.Ag),
            //                                Records.GetGlobalMeanMethod(e.RecName),
            //                                mm);
            tbp_plot.Controls.Clear();

            Chart plot = new Chart();

            plot.Dock = DockStyle.Fill;
            tbp_plot.Controls.Add(plot);

            Series SeriesB = new Series();
            Series SeriesR = new Series();

            plot.Series.Add(SeriesB);
            plot.Series.Add(SeriesR);

            //SeriesB.ToolTip = "Value: #VALY\r\nSample: #LABEL";
            //SeriesR.ToolTip = "Value: #VALY\r\nSample: #LABEL";
            ChartArea blue = new ChartArea("ChartBlue");
            ChartArea red  = new ChartArea("ChartRed");

            blue.AxisX.Title = "samples";
            red.AxisX.Title  = "samples";

            plot.ChartAreas.Add(blue);
            plot.ChartAreas.Add(red);

            SeriesB.ChartArea = "ChartBlue";
            SeriesR.ChartArea = "ChartRed";
            SeriesB.ChartType = SeriesChartType.Column;
            SeriesR.ChartType = SeriesChartType.Column;


            int i;
            int agid, agnormid;

            rv.Clear();
            rn.Clear();
            bv.Clear();
            bn.Clear();

            agid         = Records.GetAntigeneID(e.RecName, e.Ag);
            csv_ag_n     = e.Ag;
            csv_agnorm_n = e.AgNorm;

            foreach (DataRow dr in dt.Rows)
            {
                mSpotValue msvag = (mSpotValue)dr[agid];

                double agnormb, agnormr;
                if (e.AgNorm == "---")
                {
                    string    tooltip;
                    DataPoint b = new DataPoint();
                    DataPoint r = new DataPoint();

                    b.SetValueY(msvag.bvalue * 0xFFFF);
                    b.AxisLabel = msvag.subchipID;
                    //CSV
                    bv.Add(msvag.bvalue * 0xFFFF);
                    bn.Add(msvag.samplename);

                    tooltip = "Value: #VALY\r\nSample: " + msvag.samplename + "\r\nSpots used: ";
                    if (msvag.bvalid == false)
                    {
                        b.Color = Color.LightBlue;
                    }
                    else
                    {
                        b.Color = Color.Blue;
                    }
                    tooltip            += msvag.bspotsused.ToString();
                    b.ToolTip           = tooltip;
                    blue.AxisY.Title    = e.Ag;
                    blue.AxisX.Interval = 1;


                    r.SetValueY(msvag.rvalue * 0xFFFF);
                    r.AxisLabel = msvag.subchipID;
                    //CSV
                    rv.Add(msvag.rvalue * 0xFFFF);
                    rn.Add(msvag.samplename);

                    tooltip = "Value: #VALY\r\nSample: " + msvag.samplename + "\r\nSpots used: ";
                    if (msvag.bvalid == false)
                    {
                        r.Color = Color.LightCoral;
                    }
                    else
                    {
                        r.Color = Color.Red;
                    }
                    tooltip += msvag.bspotsused.ToString();

                    r.ToolTip = tooltip;

                    red.AxisY.Title    = e.Ag;
                    red.AxisX.Interval = 1;

                    SeriesB.Points.Add(b);
                    SeriesR.Points.Add(r);
                }
                else
                {
                    agnormid = Records.GetAntigeneID(e.RecName, e.AgNorm);
                    mSpotValue msvagnorm = (mSpotValue)dr[agnormid];
                    agnormb = msvagnorm.bvalue;
                    agnormr = msvagnorm.rvalue;

                    SeriesB.Points.Add(msvag.bvalue / agnormb);
                    blue.AxisY.Title = e.Ag + " / " + e.AgNorm;
                    SeriesR.Points.Add(msvag.rvalue / agnormr);
                    red.AxisY.Title = e.Ag + " / " + e.AgNorm;
                    //CSV
                    bv.Add(msvag.bvalue * 0xFFFF);
                    bn.Add(msvag.samplename);
                    rv.Add(msvag.bvalue * 0xFFFF);
                    rn.Add(msvag.samplename);
                }
            }
        }
Exemplo n.º 2
0
        public List <mSpotValue> CalculatemCSM(DataRow dr, string mm, string invh)
        {
            List <mSpotValue> retlist = new List <mSpotValue>();
            int    i, j, k;
            double m1, m2, m3;

            //DataRow dr;

            //dr = Data.Rows[ID];
            if (mm == "UK")
            {
                k = 13;
            }
            else
            {
                k = 1;
            }


            j = 0;
            for (i = 0; i < 52; ++i)
            {
                mSpotValue msv = new mSpotValue();

                //Blue channel
                m1 = Convert.ToDouble(dr[dr.Table.Columns["CSMb0"].Ordinal + j + 0 * k]);
                m2 = Convert.ToDouble(dr[dr.Table.Columns["CSMb0"].Ordinal + j + 1 * k]);
                m3 = Convert.ToDouble(dr[dr.Table.Columns["CSMb0"].Ordinal + j + 2 * k]);

                msv.bvalid     = true;
                msv.bspotsused = 3;
                double mean    = 0;
                int    divisor = 0;

                if (m1 > 2)
                {
                    m1 = m1 - 10f;
                    msv.bspotsused--;
                    msv.bvalid = false;
                }
                else
                {
                    mean += m1;
                    divisor++;
                }

                if (m2 > 2)
                {
                    m2 = m2 - 10f;
                    msv.bspotsused--;
                    msv.bvalid = false;
                }
                else
                {
                    mean += m2;
                    divisor++;
                }

                if (m3 > 2)
                {
                    m3 = m3 - 10f;
                    msv.bspotsused--;
                    msv.bvalid = false;
                }
                else
                {
                    mean += m3;
                    divisor++;
                }

                //if (invh == "Yes") msv.bvalid = true;

                msv.bvalue = (m1 + m2 + m3) / 3;

                //Red channel

                m1 = Convert.ToDouble(dr[dr.Table.Columns["CSMr0"].Ordinal + j + 0 * k]);
                m2 = Convert.ToDouble(dr[dr.Table.Columns["CSMr0"].Ordinal + j + 1 * k]);
                m3 = Convert.ToDouble(dr[dr.Table.Columns["CSMr0"].Ordinal + j + 2 * k]);

                msv.rvalid = true;

                if (m1 > 2)
                {
                    m1         = m1 - 10f;
                    msv.rvalid = false;
                }
                if (m2 > 2)
                {
                    m2         = m2 - 10f;
                    msv.rvalid = false;
                }
                if (m3 > 2)
                {
                    m3         = m3 - 10f;
                    msv.rvalid = false;
                }

                //if (invh == "Yes") msv.rvalid = true;

                msv.rvalue = (m1 + m2 + m3) / 3;

                //add samplename and subchipID
                msv.samplename = dr["samplename"].ToString();
                msv.subchipID  = dr["subchipID"].ToString();
                //add to list
                retlist.Add(msv);

                //next loop
                if (mm == "UK")
                {
                    j += 1;
                }
                else
                {
                    j += 3;
                }
            }


            return(retlist);
        }