Beispiel #1
0
def main(dataN='TCGA_GBM', query):

    con, cursor = mymysql.connectDB(db='tcga1')

    geneN, altType, feature, cutoff = query.split(':')

    cursor.execute('create temporary table t1 select samp_id pId, % value from %s where gene_sym="%s"' % \
     (altTypeH[altType][1],altTypeH[altType][0],geneN))

    cursor.execute('select value from t1')
    valueL = [v for (v, ) in cursor.fetchall()]
    l = len(valueL)

    recordL = mymysql.dictSelect(
        "SELECT pId,days_followup time,if(days_death is not null,1,0) event,%s value \
		FROM clinical join %s on pId=samp_id and gene_sym='%s'" %
        (altTypeH[altType][1], altTypeH[altType][0], geneN), cursor)

    threshold = (mymath.percentile(valueL, cutoff[0]),
                 mymath.percentile(valueL, 100 - cutoff[1]))

    outFile = open('/var/www/html/survival/survival.mvc', 'w')

    colN = ['pId', 'time', 'event', 'value', 'label', 'priority']

    outFile.write('\t'.join(colN) + '\n')

    for r in recordL:

        if r['value'] < threshold[0]:

            label = '"%s %s < B%s%% (%.2f)"' % (geneN, altType, cutoff[0],
                                                threshold[0])
            priority = '1'

        elif r['value'] >= threshold[1]:

            label = '"%s %s > T%s%% (%.2f)"' % (geneN, altType, cutoff[1],
                                                threshold[1])
            priority = '2'

        else:

            label = '"%s %s Middle"' % (geneN, altType)
            priority = '9'

        outFile.write(
            '%s\t%s\t%s\t%s\t%s\t%s\n' %
            (r['pId'], r['time'], r['event'], r['value'], label, priority))

    outFile.close()

    ret1 = os.system(
        'Rscript distribution.r /var/www/html/survival/survival.mvc &> /var/www/html/survival/error_distr.txt'
    )
    ret2 = os.system(
        'Rscript survival.r /var/www/html/survival/survival.mvc &> /var/www/html/survival/error_surv.txt'
    )

    return ret1 != 0 or ret2 != 0
Beispiel #2
0
def main(dataN='TCGA_GBM', endPoint='death',  geneN='MGMT', altType='methyl', cutoff=(50,50)):

	colN = ['pId','time','event','value','label','priority']

	con,cursor = mymysql.connectDB(db='tcga1')

	cursor.execute('select samp_id from mutation_normal where gene_symL="IDH1" and ch_aa like "%sR132%s"' % ('%','%'))
	idh1 = [x[0] for x in cursor.fetchall()]

	recordL = mymysql.dictSelect("SELECT pId,days_followup time,if(days_death is not null,1,0) event,%s value \
		FROM clinical join %s on pId=samp_id and %s='%s'" % (altTypeH[altType][1],altTypeH[altType][0],altTypeH[altType][2],geneN), cursor)

	recordL2=[]
	for i in range(len(recordL)):
		if recordL[i]['pId'] in idh1:
			continue
		else:
			recordL2.append(recordL[i])
	recordL = recordL2	
	
#	for r in recordL:
#		if r['pId'] in idh1:
#			recordL.remove(r)

	valueL = [r['value'] for r in recordL]
	l = len(valueL)

	threshold = (mymath.percentile(valueL,cutoff[0]), mymath.percentile(valueL,100-cutoff[1]))

	outFile = open('/var/www/html/tmp/survival.mvc','w')

	outFile.write('\t'.join(colN)+'\n')

	for r in recordL:

		if r['value'] < threshold[0]:

			label = '"%s %s < B%s%% (%.2f)"' % (geneN,altType,cutoff[0],threshold[0])
			priority = '1'

		elif r['value'] >= threshold[1]:

			label = '"%s %s > T%s%% (%.2f)"' % (geneN,altType,cutoff[1],threshold[1])
			priority = '2'

		else:

			label = '"%s %s Middle"' % (geneN,altType)
			priority = '9'

		outFile.write('%s\t%s\t%s\t%s\t%s\t%s\n' % (r['pId'], r['time'], r['event'], r['value'], label, priority))

	outFile.close()

	ret1 = os.system('Rscript distribution.r /var/www/html/tmp/survival.mvc &> /var/www/html/tmp/error_surv.txt')
	ret2 = os.system('Rscript survival.r /var/www/html/tmp/survival.mvc png &>> /var/www/html/tmp/error_surv.txt')
	os.system('Rscript survival.r /var/www/html/tmp/survival.mvc pdf &>> /var/www/html/tmp/error_surv.txt')

	return ret1!=0 or ret2!=0
Beispiel #3
0
def main(dataN='TCGA_GBM', query):

	con,cursor = mymysql.connectDB(db='tcga1')

	geneN,altType,feature,cutoff = query.split(':')

	cursor.execute('create temporary table t1 select samp_id pId, % value from %s where gene_sym="%s"' % \
		(altTypeH[altType][1],altTypeH[altType][0],geneN))

	cursor.execute('select value from t1')
	valueL = [v for (v,) in cursor.fetchall()]; l = len(valueL)


	recordL = mymysql.dictSelect("SELECT pId,days_followup time,if(days_death is not null,1,0) event,%s value \
		FROM clinical join %s on pId=samp_id and gene_sym='%s'" % (altTypeH[altType][1],altTypeH[altType][0],geneN), cursor)

	threshold = (mymath.percentile(valueL,cutoff[0]), mymath.percentile(valueL,100-cutoff[1]))

	outFile = open('/var/www/html/survival/survival.mvc','w')

	colN = ['pId','time','event','value','label','priority']

	outFile.write('\t'.join(colN)+'\n')

	for r in recordL:

		if r['value'] < threshold[0]:

			label = '"%s %s < B%s%% (%.2f)"' % (geneN,altType,cutoff[0],threshold[0])
			priority = '1'

		elif r['value'] >= threshold[1]:

			label = '"%s %s > T%s%% (%.2f)"' % (geneN,altType,cutoff[1],threshold[1])
			priority = '2'

		else:

			label = '"%s %s Middle"' % (geneN,altType)
			priority = '9'

		outFile.write('%s\t%s\t%s\t%s\t%s\t%s\n' % (r['pId'], r['time'], r['event'], r['value'], label, priority))

	outFile.close()

	ret1 = os.system('Rscript distribution.r /var/www/html/survival/survival.mvc &> /var/www/html/survival/error_distr.txt')
	ret2 = os.system('Rscript survival.r /var/www/html/survival/survival.mvc &> /var/www/html/survival/error_surv.txt')

	return ret1!=0 or ret2!=0
Beispiel #4
0
def main(dataN='TCGA_GBM', endPoint='death',  geneN='MGMT', altType='methyl', cutoff=(50,50)):

	colN = ['pId','time','event','value','label','priority']

	con,cursor = mymysql.connectDB(db='tcga1')

	recordL = mymysql.dictSelect("SELECT pId,days_followup time,if(days_death is not null,1,0) event,%s value \
		FROM clinical join %s on pId=samp_id and %s='%s'" % (altTypeH[altType][1],altTypeH[altType][0],altTypeH[altType][2],geneN), cursor)

	valueL = [r['value'] for r in recordL]
	l = len(valueL)

	threshold = (mymath.percentile(valueL,cutoff[0]), mymath.percentile(valueL,100-cutoff[1]))

	outFile = open('/var/www/html/tmp/survival.mvc','w')

	outFile.write('\t'.join(colN)+'\n')

	for r in recordL:

		if r['value'] < threshold[0]:

			label = '"%s %s < B%s%% (%.2f)"' % (geneN,altType,cutoff[0],threshold[0])
			priority = '1'

		elif r['value'] >= threshold[1]:

			label = '"%s %s > T%s%% (%.2f)"' % (geneN,altType,cutoff[1],threshold[1])
			priority = '2'

		else:

			label = '"%s %s Middle"' % (geneN,altType)
			priority = '9'

		outFile.write('%s\t%s\t%s\t%s\t%s\t%s\n' % (r['pId'], r['time'], r['event'], r['value'], label, priority))

	outFile.close()

	ret1 = os.system('Rscript distribution.r /var/www/html/tmp/survival.mvc &> /var/www/html/tmp/error_surv.txt')
	ret2 = os.system('Rscript survival.r /var/www/html/tmp/survival.mvc png &>> /var/www/html/tmp/error_surv.txt')
	os.system('Rscript survival.r /var/www/html/tmp/survival.mvc pdf &>> /var/www/html/tmp/error_surv.txt')

	return ret1!=0 or ret2!=0
Beispiel #5
0
def main(dataN='TCGA_GBM',
         endPoint='death',
         geneN='MGMT',
         altType='methyl',
         cutoff=(50, 50)):

    colN = ['pId', 'time', 'event', 'value', 'label', 'priority']

    con, cursor = mymysql.connectDB(db='tcga1')

    cursor.execute(
        'select samp_id from mutation_normal where gene_symL="IDH1" and ch_aa like "%sR132%s"'
        % ('%', '%'))
    idh1 = [x[0] for x in cursor.fetchall()]

    recordL = mymysql.dictSelect(
        "SELECT pId,days_followup time,if(days_death is not null,1,0) event,%s value \
		FROM clinical join %s on pId=samp_id and %s='%s'" %
        (altTypeH[altType][1], altTypeH[altType][0], altTypeH[altType][2],
         geneN), cursor)

    recordL2 = []
    for i in range(len(recordL)):
        if recordL[i]['pId'] in idh1:
            continue
        else:
            recordL2.append(recordL[i])
    recordL = recordL2

    #	for r in recordL:
    #		if r['pId'] in idh1:
    #			recordL.remove(r)

    valueL = [r['value'] for r in recordL]
    l = len(valueL)

    threshold = (mymath.percentile(valueL, cutoff[0]),
                 mymath.percentile(valueL, 100 - cutoff[1]))

    outFile = open('/var/www/html/tmp/survival.mvc', 'w')

    outFile.write('\t'.join(colN) + '\n')

    for r in recordL:

        if r['value'] < threshold[0]:

            label = '"%s %s < B%s%% (%.2f)"' % (geneN, altType, cutoff[0],
                                                threshold[0])
            priority = '1'

        elif r['value'] >= threshold[1]:

            label = '"%s %s > T%s%% (%.2f)"' % (geneN, altType, cutoff[1],
                                                threshold[1])
            priority = '2'

        else:

            label = '"%s %s Middle"' % (geneN, altType)
            priority = '9'

        outFile.write(
            '%s\t%s\t%s\t%s\t%s\t%s\n' %
            (r['pId'], r['time'], r['event'], r['value'], label, priority))

    outFile.close()

    ret1 = os.system(
        'Rscript distribution.r /var/www/html/tmp/survival.mvc &> /var/www/html/tmp/error_surv.txt'
    )
    ret2 = os.system(
        'Rscript survival.r /var/www/html/tmp/survival.mvc png &>> /var/www/html/tmp/error_surv.txt'
    )
    os.system(
        'Rscript survival.r /var/www/html/tmp/survival.mvc pdf &>> /var/www/html/tmp/error_surv.txt'
    )

    return ret1 != 0 or ret2 != 0
Beispiel #6
0
def main(dataN='TCGA_GBM',
         endPoint='death',
         geneN='MGMT',
         altType='methyl',
         cutoff=(50, 50)):

    colN = ['pId', 'time', 'event', 'value', 'label', 'priority']

    con, cursor = mymysql.connectDB(db='tcga1')

    recordL = mymysql.dictSelect(
        "SELECT pId,days_followup time,if(days_death is not null,1,0) event,%s value \
		FROM clinical join %s on pId=samp_id and %s='%s'" %
        (altTypeH[altType][1], altTypeH[altType][0], altTypeH[altType][2],
         geneN), cursor)

    valueL = [r['value'] for r in recordL]
    l = len(valueL)

    threshold = (mymath.percentile(valueL, cutoff[0]),
                 mymath.percentile(valueL, 100 - cutoff[1]))

    outFile = open('/var/www/html/tmp/survival.mvc', 'w')

    outFile.write('\t'.join(colN) + '\n')

    for r in recordL:

        if r['value'] < threshold[0]:

            label = '"%s %s < B%s%% (%.2f)"' % (geneN, altType, cutoff[0],
                                                threshold[0])
            priority = '1'

        elif r['value'] >= threshold[1]:

            label = '"%s %s > T%s%% (%.2f)"' % (geneN, altType, cutoff[1],
                                                threshold[1])
            priority = '2'

        else:

            label = '"%s %s Middle"' % (geneN, altType)
            priority = '9'

        outFile.write(
            '%s\t%s\t%s\t%s\t%s\t%s\n' %
            (r['pId'], r['time'], r['event'], r['value'], label, priority))

    outFile.close()

    ret1 = os.system(
        'Rscript distribution.r /var/www/html/tmp/survival.mvc &> /var/www/html/tmp/error_surv.txt'
    )
    ret2 = os.system(
        'Rscript survival.r /var/www/html/tmp/survival.mvc png &>> /var/www/html/tmp/error_surv.txt'
    )
    os.system(
        'Rscript survival.r /var/www/html/tmp/survival.mvc pdf &>> /var/www/html/tmp/error_surv.txt'
    )

    return ret1 != 0 or ret2 != 0