Skip to content

Commit

Permalink
v 16
Browse files Browse the repository at this point in the history
  • Loading branch information
marouenbg committed Sep 21, 2024
1 parent cf7f3c1 commit a940642
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ def handle(self, *args, **options):
tissuesamplethy.link = row['link']
tissuesamplethy.size = row['size']
tissuesamplethy.cleanname = row['cleanname']
tissuesamplethy.decsex = row['decoded_sex']
tissuesamplethy.save()
2 changes: 2 additions & 0 deletions grandapp/management/commands/load_tissuelanding_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def handle(self, *args, **options):
tissuelanding.ppi = row['ppi']
tissuelanding.ppiLink = row['ppiLink']
tissuelanding.motif = row['motif']
tissuelanding.motif2 = row['motif2']
tissuelanding.motifDesc = row['motifDesc']
tissuelanding.motifDesc2 = row['motifDesc2']
tissuelanding.expression = row['expression']
tissuelanding.expLink = row['expLink']
tissuelanding.tfs = row['tfs']
Expand Down
25 changes: 25 additions & 0 deletions grandapp/migrations/0249_auto_20240816_1511.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.2.5 on 2024-08-16 15:11

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('grandapp', '0248_tissuelanding_cardtissue'),
]

operations = [
migrations.AddField(
model_name='tissuelanding',
name='motif2',
field=models.URLField(default=''),
preserve_default=False,
),
migrations.AddField(
model_name='tissuelanding',
name='motifDesc2',
field=models.CharField(default='', max_length=200),
preserve_default=False,
),
]
19 changes: 19 additions & 0 deletions grandapp/migrations/0250_tissuesamplethy_decsex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.5 on 2024-08-16 20:01

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('grandapp', '0249_auto_20240816_1511'),
]

operations = [
migrations.AddField(
model_name='tissuesamplethy',
name='decsex',
field=models.CharField(default='', max_length=600),
preserve_default=False,
),
]
3 changes: 3 additions & 0 deletions grandapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ class Tissuelanding(models.Model):
ppi = models.URLField()
ppiLink = models.URLField()
motif = models.URLField()
motif2 = models.URLField()
motifDesc = models.CharField(max_length=200)
motifDesc2 = models.CharField(max_length=200)
expression= models.URLField()
expLink = models.URLField()
tfs = models.IntegerField()
Expand Down Expand Up @@ -344,6 +346,7 @@ class Tissuesamplethy(models.Model):
smgnsdtc = models.CharField(max_length=600)
cleanname = models.CharField(max_length=600)
proxage = models.CharField(max_length=600)
decsex = models.CharField(max_length=600)

class Tissuesample(models.Model):
sampleid = models.CharField(max_length=600)
Expand Down
2 changes: 1 addition & 1 deletion grandapp/templates/geobrca.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h5 class="card-title">Variable description</h5>
<tbody>
{% for tissue in geosample %}
<tr>
<td>{{ tissue.sample }}</td>
<td><a href="/networks/aggregate/{{ tissue.sampleclean }}" style="text-decoration:none">{{ tissue.sample }}</a></td>
<td>{{ tissue.gender }}</td>
<td>{{ tissue.subtype }}</td>
<td>{{ tissue.mutation }}</td>
Expand Down
2 changes: 1 addition & 1 deletion grandapp/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<header class="jumbotron jumbotron-fluid">
<div class="container">
<div class="display-2 mb-4"></div>
<p class="lead" align="center">GRAND is a collection of gene regulatory networks derived from <a href="/tissues" class="text-decoration-none">human tissues</a>, <a href="/cancers" class="text-decoration-none">cancer</a>, <a href="/cell" class="text-decoration-none">cell lines</a>, and <a href="/drugs" class="text-decoration-none">small molecule</a> drugs. These networks are bipartite graphs linking either transcription factors (TFs) or miRNAs to their target genes. GRAND includes an integrated webserver to test for <a href='/disease' class="text-decoration-none">enrichment</a> of a list of TFs in a set of libraries as well as a tool (CLUEreg) to <a href="/analysis" class="text-decoration-none">find compounds</a> that reverse/exacerbate a gene or TF regulatory profile.<br> Publication: Ben Guebila, Lopes-Ramos et al. <a href="https://academic.oup.com/nar/advance-article/doi/10.1093/nar/gkab778/6368528" style="text-decoration:none;" target=”_blank”>NAR, 2022.</a> Current version: <a href="https://github.com/QuackenbushLab/grand/releases/tag/1.6.0" style="text-decoration:none;" target=”_blank”>1.6.0</a>. Last update: 08/06/2024.<br>
<p class="lead" align="center">GRAND is a collection of gene regulatory networks derived from <a href="/tissues" class="text-decoration-none">human tissues</a>, <a href="/cancers" class="text-decoration-none">cancer</a>, <a href="/cell" class="text-decoration-none">cell lines</a>, and <a href="/drugs" class="text-decoration-none">small molecule</a> drugs. These networks are bipartite graphs linking either transcription factors (TFs) or miRNAs to their target genes. GRAND includes an integrated webserver to test for <a href='/disease' class="text-decoration-none">enrichment</a> of a list of TFs in a set of libraries as well as a tool (CLUEreg) to <a href="/analysis" class="text-decoration-none">find compounds</a> that reverse/exacerbate a gene or TF regulatory profile.<br> Publication: Ben Guebila, Lopes-Ramos et al. <a href="https://academic.oup.com/nar/advance-article/doi/10.1093/nar/gkab778/6368528" style="text-decoration:none;" target=”_blank”>NAR, 2022.</a> Current version: <a href="https://github.com/QuackenbushLab/grand/releases/tag/1.6.0" style="text-decoration:none;" target=”_blank”>1.6.0</a>. Last update: 09/21/2024.<br>
</p>
</div>
</header>
Expand Down
4 changes: 2 additions & 2 deletions grandapp/templates/networksagg.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ <h5><span data-step="2" data-intro="Since these are genome-scale network, we can
data-bs-animation="false"
data-bs-placement="top"
data-bs-html="true"
data-bs-content="Draws motif prior edges as dashed lines.">
data-bs-content="Draws motif prior edges as dashed lines. For sex-specific networks, motif prior edges are specific to males and females.">
Prior edges</a></small>
</div>
</div>
Expand All @@ -188,7 +188,7 @@ <h5><span class="badge bg-secondary">Node scaling</span></h5>
data-bs-animation="false"
data-bs-placement="top"
data-bs-html="true"
data-bs-content="Scale node size by average expression across samples for aggregate networks and by sample for single-sample networks.">
data-bs-content="Scale node size by average expression across samples for aggregate networks; for single-sample networks, node size is also the average across all samples as well; for sex-specific networks, node size is the average across males if patient is male and across females if patient is female.">
expression</a></small>
</div>
<div style="float: left;">
Expand Down
6 changes: 4 additions & 2 deletions grandapp/templates/tissueslanding.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h5 class="card-title">Tool description</h5>
<p class="card-text"><a href="https://netzoo.github.io/zooanimals/panda/" style="text-decoration:none" target="_blank">PANDA</a> reconstructs a gene regulatory network using TF PPI, TF DNA binding motif as regulation prior, and gene expression samples.
<a href="https://netzoo.github.io/zooanimals/puma/" style="text-decoration:none" target="_blank">PUMA</a> reconstructs a gene regulatory network with miRNA as regulators using gene expression samples and miRNA predicted targets by <a href="http://cbio.mskcc.org/microrna_data/manual.html" style="text-decoration:none" target="_blank">miRanda</a> or <a href="http://www.targetscan.org/vert_72/" style="text-decoration:none" target="_blank">TargetScan</a> as regulation priors. The Regulator-regulator interaction matrix is set to the identity matrix in the algorithm.
{% if name == 'yes' %} <a href="https://netzoo.github.io/zooanimals/lioness/" style="text-decoration:none" target="_blank">LIONESS</a> reconstructs patient-specific <a href="https://netzoo.github.io/zooanimals/panda/" style="text-decoration:none" target="_blank">PANDA</a> networks for each gene expression sample.
<a href="https://netzoo.github.io/zooanimals/ss/bonobo/" style="text-decoration:none" target="_blank">BONOBO</a> is a single-sample network inference method, which can be used to estimate patient-specific co-expression matrices.
<p><a href="https://netzoo.github.io/zooanimals/ss/bonobo/" style="text-decoration:none" target="_blank">BONOBO</a> is a single-sample network inference method, which can be used to estimate patient-specific co-expression matrices, which are then fed as input for PANDA to build patient-specific GRNs. To adapt BONOBO-PANDA networks for patient's sex, and in addition to sample-specific co-expression, PANDA's motif prior networks are constructed for each sex (accounting for <a href="https://genome.cshlp.org/content/early/2024/08/10/gr.279117.124.abstract" style="text-decoration:none" target="_blank">sex chromosomes</a>), while the third input (PPI networks) are generic for all patients.
To download sample-specific networks, you can check <a href="#cardtissue" style="text-decoration:none">the phenotypic information</a> and select the networks by
clinical variables or download all the samples in a single file. {% else %} Check <a href="#cardtissue" style="text-decoration:none" >the phenotypic information</a> for the clinical variables of the samples that were used to reconstruct the network. {% endif %}</p>
<table id="tissuestable2" class="table table-hover" width="100%">
Expand Down Expand Up @@ -137,7 +137,7 @@ <h5 class="card-title">Tool description</h5>
{% else %}
<td><a href="{{ tissue.ppi }}"><i class="fas fa-download"></i></a> <a href="{{ tissue.ppiLink }}" target="_blank"><i class="fas fa-link"></i></a></td>
{% endif %}
<td><a href="{{ tissue.motif }}" class="text-decoration-none">{{ tissue.motifDesc }}</a></td>
<td><a href="{{ tissue.motif }}" class="text-decoration-none">{{ tissue.motifDesc }}</a>{% if tissue.tool == 'BONOBO-PANDA' %}, <a href="{{ tissue.motif2 }}" class="text-decoration-none">{{ tissue.motifDesc2 }}</a>{% endif %}</td>
<td><a href="{{ tissue.expression }}"><i class="fas fa-download"></i></a> <a href="{{ tissue.expLink }}" target="_blank"><i class="fas fa-link"></i></a></td>
<td>{{ tissue.reg }}</td>
<td>{{ tissue.tfs }}</td>
Expand Down Expand Up @@ -408,7 +408,9 @@ <h5 class="card-title">Variable description</h5>
</div>
</div>
</div>
{% if slug2 == 'Thyroid' %}
{% include "bonobothy.html" %}
{% endif %}
</div>
</div>

Expand Down
48 changes: 36 additions & 12 deletions grandapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def networksagg(request,slug):
edges['dispval'] =1
nodes=nodes.to_json(orient='records')
edges=edges.to_json(orient='records')
object_key,ssagg,categorynet,regnetdisp,backpage,attr1,attr2,attr3,attr4,attr11,attr12,attr13,attr14=mapObjectkey(slug)
object_key,ssagg,categorynet,regnetdisp,backpage,attr1,attr2,attr3,attr4,attr11,attr12,attr13,attr14,mid,fid=mapObjectkey(slug)
# Targeting form
formtar = TarForm({'topbottomtar':'Largest','nedgestar':100,'topbottomtartf':'Largest','nedgestartf':100,'tfgeneseltar':'nosel'})
clueform = ClueForm({'tfgeneselclue':'by gene'})
Expand All @@ -173,24 +173,30 @@ def networksagg(request,slug):
if (slug[0:3]=='ACH') | (slug=='mirnadragon') | (slugsplit=='bonobo'):
form.fields['edgetargeting'].widget.attrs['disabled'] = 'disabled'
print('The number of edges is',nedges)
object_key,ssagg,categorynet,regnetdisp,backpage,attr1,attr2,attr3,attr4,attr11,attr12,attr13,attr14=mapObjectkey(slug)
print('hey')
object_key,ssagg,categorynet,regnetdisp,backpage,attr1,attr2,attr3,attr4,attr11,attr12,attr13,attr14,mid,fid=mapObjectkey(slug)
print(object_key)
print(dt)
df=fetchNetwork(object_key)
if dt=='dtt':
tftar = df.sum(axis=1)
genetar= df.sum(axis=0)
if dt=='dee':
object_key,ew1,ew2,ew3,ew4,attr1,attr2,attr3,attr4,attr11,attr12,attr13,attr14=mapObjectkey(slug,modality='expression')
object_key,ew1,ew2,ew3,ew4,attr1,attr2,attr3,attr4,attr11,attr12,attr13,attr14,mid,fid=mapObjectkey(slug,modality='expression')
print(attr2)
print(object_key)
deDf=fetchNetwork(object_key)
if attr2=='MALE':
deDf=fetchNetwork(object_key,sexind=mid)
elif attr2=='FEMALE':
deDf=fetchNetwork(object_key,sexind=fid)
else:
deDf=fetchNetwork(object_key)
deDfmean = deDf.values.mean()
deDf = deDf.mean(axis=1)
df.index.name='TF'
df,found,ngwas,ngenesfound=selectgenes(df,tfgenesel,geneform,tfform,goform,gwasform)
df=df.stack().reset_index().rename(columns={'TF':'source','level_1':'target', 0:'value'})
if edgetargeting == 'on':
object_key,ew1,ew2,ew3,ew4,attr1,attr2,attr3,attr4,attr11,attr12,attr13,attr14=mapObjectkey(slug,modality='motif')
object_key,ew1,ew2,ew3,ew4,attr1,attr2,attr3,attr4,attr11,attr12,attr13,attr14,mid,fid=mapObjectkey(slug,modality='motif',sex=attr2)
motif=fetchNetwork(object_key,how='motif')
motif=motif[motif['value'] >0]
df = pd.merge(df, motif, how ='left', on =['source', 'target'])
Expand Down Expand Up @@ -2296,7 +2302,7 @@ def selectgenes(df,tfgenesel,geneform,tfform,goform,gwasform):
print('no intersection')
return df, found, ngwas, ngenesfound

def fetchNetwork(object_key,how='net'):
def fetchNetwork(object_key,how='net',sexind=[]):
client = boto3.client('s3')
bucket_name = 'granddb'
csv_obj = client.get_object(Bucket=bucket_name, Key=object_key)
Expand All @@ -2307,6 +2313,8 @@ def fetchNetwork(object_key,how='net'):
df = pd.read_csv(StringIO(csv_string),index_col=0,sep='\t')
else:
df = pd.read_csv(StringIO(csv_string),index_col=0,sep=',')
if len(sexind) != 0:
df=df.iloc[:,sexind]
elif how=='motif':
if (str.split(object_key,'_')[-2] == 'otter') | (str.split(object_key,'/')[-1][0:3]=='GSM'):
df = pd.read_csv(StringIO(csv_string), sep=',',index_col=0)
Expand Down Expand Up @@ -2376,9 +2384,9 @@ def selectgenestar(genetarscore,tfgenesel,geneform,goform,gwasform):
found='not found'
return genetarscore, found, ngwas, ngenesfound

def mapObjectkey(slug,modality='network',how=''):
def mapObjectkey(slug,modality='network',how='',sex=''):
regnetdisp='Transcription factor'
attr1,attr2,attr3,attr4,attr11,attr12,attr13,attr14='','','','','','','',''
attr1,attr2,attr3,attr4,attr11,attr12,attr13,attr14,fid,mid='','','','','','','','','',''
if len(slug.split('_')) > 2:
slugsplit = slug.split('_')[2]
else:
Expand Down Expand Up @@ -2583,12 +2591,28 @@ def mapObjectkey(slug,modality='network',how=''):
attr13 = 'Estrogen receptor status'
attr14 = 'HER2 receptor status'
elif (slugsplit == 'BONOBO'): # bonobo panda thyroid network
print('ho')
print(slug[17:])
object_key = 'tissues/networks/panda_bonobo/THY_PANDA_BONOBO_'+slug[17:].replace('_','-')+'.csv'
backpage = 'tissues/Thyroid_tissue'
ssagg='Single sample'
categorynet='Tissues'
if modality == 'motif':
if sex=='MALE':
object_key='tissues/motif/MotifPriorGencode_p5.txt'
elif sex=='FEMALE':
object_key='tissues/motif/MotifPriorGencode_p5_female_PARonX.txt'
elif modality=='expression':
object_key = 'tissues/expression/GTEx_thyroid_allSex.txt'
tissuesample = Tissuesamplethy.objects.get(sampleid=slug[-24:].replace('_','-'))
mid=np.array(list(Tissuesamplethy.objects.filter(decsex='MALE').values_list('pk', flat=True)), dtype='int')-1
fid=np.array(list(Tissuesamplethy.objects.filter(decsex='FEMALE').values_list('pk', flat=True)), dtype='int')-1
attr1 = tissuesample.smts
attr2 = tissuesample.decsex
attr3 = tissuesample.age
attr4 = tissuesample.subjectid
attr11 = 'Tissue'
attr12 = 'Donor Gender'
attr13 = 'Donor age'
attr14 = 'Subject'
elif (str.split(slug,'_')[2] == 'TCGA') | (str.split(slug,'_')[2][0:3] == 'GSM'): # single sample networks
ssagg='Single sample'
categorynet='Cancer'
Expand Down Expand Up @@ -2668,4 +2692,4 @@ def mapObjectkey(slug,modality='network',how=''):
categorynet='Cell lines'
backpage='cell/gm12878'
object_key = 'data/' + str.split(slug,'_')[0] + '_' + str.split(slug,'_')[1] + '.csv'
return object_key, ssagg, categorynet, regnetdisp, backpage, attr1, attr2, attr3, attr4, attr11, attr12, attr13, attr14
return object_key, ssagg, categorynet, regnetdisp, backpage, attr1, attr2, attr3, attr4, attr11, attr12, attr13, attr14, mid, fid

0 comments on commit a940642

Please sign in to comment.