Skip to content

Commit

Permalink
Merge pull request #8 from GenomiqueENS/gh-page
Browse files Browse the repository at this point in the history
New design for improved traceability
  • Loading branch information
alihamraoui authored Aug 2, 2024
2 parents c245d7c + d99ed99 commit 9e26dd2
Show file tree
Hide file tree
Showing 9 changed files with 496 additions and 73 deletions.
68 changes: 66 additions & 2 deletions bin/QC.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@
from libs.figs import ATGC_graph
from libs.figs import GC_content_plot
from libs.report import make_report
from libs.reporte_maker import reporter
import plotly.graph_objects as go

parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('-q', '--fastq', action='append', dest='fastq', required=True,
help='FASTQ file (necessary if no sequencing summary file), ' +
'can also be in a tar.gz archive')
parser.add_argument('-r', "--conf_params", action='append', dest="conf_params", help="config parameters")
parser.add_argument('-w', "--work_params", action='append', dest="work_params", help="workflow parameters")
parser.add_argument('-e', "--env", action='append', dest="env", help="packages versions")

parser.add_argument('-s', "--stats", action='store', dest="stats", help="template maker stats")
parser.add_argument('-p', "--positions", action='store', dest="positions", help="Number of base position to show", type=int, default=1000)
parser.add_argument('-t', "--thread", action='store', dest="thread", help="Number of threads", type=int, default=2)
parser.add_argument('-b', "--batch-size", action='store', dest="batch_size", help="Batch size", type=int, default=500)
parser.add_argument('-n', "--project", action='store', dest="project", help="project name", type=str, default="test_project")
args = parser.parse_args()


columns = ["pos",
"Q_score",
"GC_content",
Expand Down Expand Up @@ -46,6 +52,50 @@ def compQC(fastq, positions, reverse=False):
return df_stats, df_qc, positions, q_scores, q1, q3


def pie_unknown(df):
labels = ['Simulated feature counts','Unknow feature counts']
values = [int(df['Simulated UMI counts']),
int(df['Unknown transcript counts'])]

fig = go.Figure(data=[go.Pie(labels=labels, values=values, pull=[0, 0, 0.2, 0])])
return fig


def create_table(stats_data, table_width=500, table_height=400, margin=10):
data=[go.Table(
header=dict(
values=['', '<b>Value</b>'],
fill_color='#EBEBEB', # Couleur de fond de l'en-tête
font=dict(color='black', size=12) # Couleur et taille du texte de l'en-tête
),
cells=dict(
values=[
['<b>Simulated Cell BC</b>', '<b>Simulated Filtered-Out</b>', '<b>Simulated UMI counts</b>', '<b>Mean UMI per cell</b>'],
[
stats_data['Simulated Cell BC'],
stats_data['Simulated Filtered-Out'],
stats_data['Simulated UMI counts'],
int(int(stats_data['Simulated UMI counts']) / int(stats_data['Simulated Cell BC']))
]
],
fill_color='#f4f4f4', # Couleur de fond des cellules
font=dict(color='black', size=11) # Couleur et taille du texte des cellules
)
)]

fig = go.Figure(data)

fig.update_layout(
#width=table_width,
#height=table_height,
margin=dict(l=margin,
r=margin,
t=20,
b=0),
)
return fig


def main():
df_stats, df_qc, pos, q_scores, q1, q3 = compQC(args.fastq, args.positions)
df_stats_rev, df_qc_rev, pos_rev, q_scores_rev, q1_rev, q3_rev = compQC(args.fastq, args.positions, reverse=True)
Expand Down Expand Up @@ -77,7 +127,21 @@ def main():

gc = GC_content_plot(df_stats['GC_percentage'])

make_report(Q_over_time, atgc, gc, args.project, args.positions)
df_stats = pd.read_csv(args.stats)
pie_fig = pie_unknown(df_stats)
stats_table = create_table(df_stats)

#make_report(Q_over_time, atgc, gc, args.project, args.positions)
reporter(stats_table,
pie_fig,
Q_over_time,
atgc,
gc,
args.conf_params,
args.work_params,
args.project,
args.env)


if __name__ == "__main__":
main()
Expand Down
174 changes: 174 additions & 0 deletions bin/libs/css_style.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
from dominate.util import raw

def _summary(graphs):
"""
Compose the summary section of the page
:param graphs:
:return: a string with HTML code for the module list
"""
result = " <ul class=\"menu-vertical\">\n"
for i, t in enumerate(graphs):
result += " <li class=\"mv-item\"><a href=\"#M" + str(i) + "\">" + t + "</a></li>\n"
result += " </ul>\n"
return result


def div_summary_style(titles):
style = """
<style>
#leftCol {
position: -webkit-sticky;
position: sticky;
top: 10px;
font-size: 0.9em;
margin: 0.5em 0 0 0.5em;
width: calc(250px - 0.01em);
}
.qc-toc {
display: none;
}
.qc-report .qc-toc {
display: flex;
}
.menu-vertical {
right: 1em;
padding: 1px;
margin-right : 1em;
list-style: none;
text-align: left;
background: #F2F2F2;
}
.mv-item, .mv-item a {
display: block;
}
.mv-item a {
margin: 1px 0;
padding: 8px 20px;
color: #666;
background: #FFF;
text-decoration: none;
transition: all .3s;
}
.mv-item a:hover, .mv-item a:focus {
background: rgba(var(--bs-dark-rgb), var(--bs-bg-opacity)) !important;
color: #FFF;
padding-left: 30px;
}
.mv-item a:enabled {
font-weight: bold;
}
</style>
"""
menu = """
<div id="leftCol">
<!--h2>Summary</h2-->
{summary_list}
</div>
""".format(summary_list=_summary(titles))
html = style+menu
return html


def head_style():
style = raw(f"""
body {{ font-family: Arial, sans-serif; }}
header {{ display: flex;
justify-content: space-between;
align-items: center;
background-color: #EBEBEB;
padding: 10px 20px;
border-bottom: 1px solid #ddd; }}
h1.title {{ font-size: 14px; }}
h1.title2 {{
font-size: 16px;
max-width: 400px;
border-bottom: 2px solid #000000; /* Exemple avec une bordure noire de 2px */
padding-bottom: 10px; /* Ajoute un peu d'espace entre le texte et la bordure */
}}
p.date {{ font-size: 12px;
color: #666; }}
.container {{ display: flex;
justify-content: space-between;
background-color: #FFFFFF}}
.content {{ flex: 2;
padding: 20px;
max-width: 1400px;
margin-left: 0;
margin-right: auto;
}}
.aside {{ flex: 1; border-right: 1px solid #ddd; padding: 20px; }}
.tabs {{ display: flex;
margin-top: 20px;
margin-bottom: 20px; }}
.tab-button {{
background-color: #f4f4f4;
padding: 10px;
cursor: pointer;
border: none;
border-radius: 4px;
}}
.tab-button.active {{
background-color: #052F61;
color: white;
border-radius: 10px;
}}
.tab-content {{ display: none; }}
.tab-content.active {{ display: block; }}
""")
return style


def body_style():
style = """
body {
font-family: 'Arial', sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
.table-container {
width: 80%;
margin: 50px auto;
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
table {
width: 100%;
font-size: 14px;
border-collapse: collapse;
background-color: #fff;
border-radius: 8px;
overflow: hidden;
}
th, td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #EBEBEB;
color: #666;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #e9f1fe;
}
"""
return style
Loading

0 comments on commit 9e26dd2

Please sign in to comment.