Skip to content

Commit

Permalink
Merge pull request #9 from bigbio/dev
Browse files Browse the repository at this point in the history
u
  • Loading branch information
daichengxin authored May 18, 2022
2 parents 8361c38 + a30389f commit 7e13421
Show file tree
Hide file tree
Showing 30 changed files with 629 additions and 294 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Check PRs
if: github.repository == 'nf-core/quantms'
run: |
"{ [[ ${{github.event.pull_request.head.repo.full_name }} == nf-core/quantms ]] && [[ $GITHUB_HEAD_REF = "dev" ]]; } || [[ $GITHUB_HEAD_REF == "patch" ]]"
{ [[ ${{github.event.pull_request.head.repo.full_name }} == nf-core/quantms ]] && [[ $GITHUB_HEAD_REF = "dev" ]]; } || [[ $GITHUB_HEAD_REF == "patch" ]]
# If the above check failed, post a comment on the PR explaining the failure
# NOTE - this doesn't currently work if the PR is coming from a fork, due to limitations in GitHub actions secrets
Expand Down Expand Up @@ -42,4 +42,3 @@ jobs:
Thanks again for your contribution!
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: false
#
55 changes: 55 additions & 0 deletions .github/workflows/fix-linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Fix linting from a comment
on:
issue_comment:
types: [created]

jobs:
deploy:
# Only run if comment is on a PR with the main repo, and if it contains the magic keywords
if: >
contains(github.event.comment.html_url, '/pull/') &&
contains(github.event.comment.body, '@nf-core-bot fix linting') &&
github.repository == 'nf-core/quantms'
runs-on: ubuntu-latest
steps:
# Use the @nf-core-bot token to check out so we can push later
- uses: actions/checkout@v3
with:
token: ${{ secrets.nf_core_bot_auth_token }}

# Action runs on the issue comment, so we don't get the PR by default
# Use the gh cli to check out the PR
- name: Checkout Pull Request
run: gh pr checkout ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.nf_core_bot_auth_token }}

- uses: actions/setup-node@v2

- name: Install Prettier
run: npm install -g prettier @prettier/plugin-php

# Check that we actually need to fix something
- name: Run 'prettier --check'
id: prettier_status
run: |
if prettier --check ${GITHUB_WORKSPACE}; then
echo "::set-output name=result::pass"
else
echo "::set-output name=result::fail"
fi
- name: Run 'prettier --write'
if: steps.prettier_status.outputs.result == 'fail'
run: prettier --write ${GITHUB_WORKSPACE}

- name: Commit & push changes
if: steps.prettier_status.outputs.result == 'fail'
run: |
git config user.email "[email protected]"
git config user.name "nf-core-bot"
git config push.default upstream
git add .
git status
git commit -m "[automated] Fix linting with Prettier"
git push
4 changes: 1 addition & 3 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
wget -qO- get.nextflow.io | bash
sudo mv nextflow /usr/local/bin/
- uses: actions/setup-python@v1
- uses: actions/setup-python@v3
with:
python-version: "3.6"
architecture: "x64"
Expand Down Expand Up @@ -78,5 +78,3 @@ jobs:
lint_log.txt
lint_results.md
PR_number.txt
#
1 change: 0 additions & 1 deletion .github/workflows/linting_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ steps.pr_number.outputs.pr_number }}
path: linting-logs/lint_results.md
#
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
email_template.html
.nextflow*
work/
data/
results/
.DS_Store
testing/
testing*
*.pyc
142 changes: 42 additions & 100 deletions assets/email_template.html
Original file line number Diff line number Diff line change
@@ -1,111 +1,53 @@
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- prettier-ignore -->
<meta name="description" content="nf-core/quantms: Quantitative Mass Spectrometry nf-core workflow" />
<title>nf-core/quantms Pipeline Report</title>
</head>
<body>
<div style="font-family: Helvetica, Arial, sans-serif; padding: 30px; max-width: 800px; margin: 0 auto">
<img src="cid:nfcorepipelinelogo" />
<meta name="description" content="nf-core/quantms: Quantitative Mass Spectrometry nf-core workflow">
<title>nf-core/quantms Pipeline Report</title>
</head>
<body>
<div style="font-family: Helvetica, Arial, sans-serif; padding: 30px; max-width: 800px; margin: 0 auto;">

<h1>nf-core/quantms v${version}</h1>
<h2>Run Name: $runName</h2>
<img src="cid:nfcorepipelinelogo">

<% if (!success){ out << """
<div
style="
color: #a94442;
background-color: #f2dede;
border-color: #ebccd1;
padding: 15px;
margin-bottom: 20px;
border: 1px solid transparent;
border-radius: 4px;
"
>
<h4 style="margin-top: 0; color: inherit">nf-core/quantms execution completed unsuccessfully!</h4>
<h1>nf-core/quantms v${version}</h1>
<h2>Run Name: $runName</h2>

<% if (!success){
out << """
<div style="color: #a94442; background-color: #f2dede; border-color: #ebccd1; padding: 15px; margin-bottom: 20px; border: 1px solid transparent; border-radius: 4px;">
<h4 style="margin-top:0; color: inherit;">nf-core/quantms execution completed unsuccessfully!</h4>
<p>The exit status of the task that caused the workflow execution to fail was: <code>$exitStatus</code>.</p>
<p>The full error message was:</p>
<pre style="white-space: pre-wrap; overflow: visible; margin-bottom: 0">${errorReport}</pre>
</div>
""" } else { out << """
<div
style="
color: #3c763d;
background-color: #dff0d8;
border-color: #d6e9c6;
padding: 15px;
margin-bottom: 20px;
border: 1px solid transparent;
border-radius: 4px;
"
>
<pre style="white-space: pre-wrap; overflow: visible; margin-bottom: 0;">${errorReport}</pre>
</div>
"""
} else {
out << """
<div style="color: #3c763d; background-color: #dff0d8; border-color: #d6e9c6; padding: 15px; margin-bottom: 20px; border: 1px solid transparent; border-radius: 4px;">
nf-core/quantms execution completed successfully!
</div>
""" } %>
</div>
"""
}
%>

<p>The workflow was completed at <strong>$dateComplete</strong> (duration: <strong>$duration</strong>)</p>
<p>The command used to launch the workflow was as follows:</p>
<pre
style="
white-space: pre-wrap;
overflow: visible;
background-color: #ededed;
padding: 15px;
border-radius: 4px;
margin-bottom: 30px;
"
>
$commandLine</pre
>
<p>The workflow was completed at <strong>$dateComplete</strong> (duration: <strong>$duration</strong>)</p>
<p>The command used to launch the workflow was as follows:</p>
<pre style="white-space: pre-wrap; overflow: visible; background-color: #ededed; padding: 15px; border-radius: 4px; margin-bottom:30px;">$commandLine</pre>

<h3>Pipeline Configuration:</h3>
<table
style="
width: 100%;
max-width: 100%;
border-spacing: 0;
border-collapse: collapse;
border: 0;
margin-bottom: 30px;
"
>
<tbody style="border-bottom: 1px solid #ddd">
<% out << summary.collect{ k,v -> "
<tr>
<th
style="
text-align: left;
padding: 8px 0;
line-height: 1.42857143;
vertical-align: top;
border-top: 1px solid #ddd;
"
>
$k
</th>
<td
style="
text-align: left;
padding: 8px;
line-height: 1.42857143;
vertical-align: top;
border-top: 1px solid #ddd;
"
>
<pre style="white-space: pre-wrap; overflow: visible">$v</pre>
</td>
</tr>
" }.join("\n") %>
</tbody>
</table>
<h3>Pipeline Configuration:</h3>
<table style="width:100%; max-width:100%; border-spacing: 0; border-collapse: collapse; border:0; margin-bottom: 30px;">
<tbody style="border-bottom: 1px solid #ddd;">
<% out << summary.collect{ k,v -> "<tr><th style='text-align:left; padding: 8px 0; line-height: 1.42857143; vertical-align: top; border-top: 1px solid #ddd;'>$k</th><td style='text-align:left; padding: 8px; line-height: 1.42857143; vertical-align: top; border-top: 1px solid #ddd;'><pre style='white-space: pre-wrap; overflow: visible;'>$v</pre></td></tr>" }.join("\n") %>
</tbody>
</table>

<p>nf-core/quantms</p>
<p><a href="https://github.com/nf-core/quantms">https://github.com/nf-core/quantms</a></p>
</div>
</body>
<p>nf-core/quantms</p>
<p><a href="https://github.com/nf-core/quantms">https://github.com/nf-core/quantms</a></p>

</div>

</body>
</html>
4 changes: 2 additions & 2 deletions bin/diann_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def convert(ctx, diann_report, exp_design):
out_triqler.loc[:, "searchScore"] = 1 - report['PEP']

out_msstats = out_msstats[out_msstats["Intensity"] != 0]
out_msstats.to_csv('./out_msstats.csv', sep=',', index=False)
out_msstats.to_csv(os.path.splitext(os.path.basename(exp_design))[0] + '_out_msstats.csv', sep=',', index=False)
out_triqler = out_triqler[out_triqler["intensity"] != 0]
out_triqler.to_csv('./out_triqler.tsv', sep='\t', index=False)
out_triqler.to_csv(os.path.splitext(os.path.basename(exp_design))[0] + '_out_triqler.tsv', sep='\t', index=False)

def query_expdesign_value(reference, f_table, s_table):
query_reference = f_table[f_table["run"] == reference]
Expand Down
21 changes: 13 additions & 8 deletions bin/msstats_plfq.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,21 @@ if (l == 1) {
#write all comparisons into one CSV file
write.table(test.MSstats$ComparisonResult, file=paste0(args[8],"_comparisons.csv"), quote=FALSE, sep='\t', row.names = FALSE)

groupComparisonPlots(data=test.MSstats$ComparisonResult, type="ComparisonPlot",
width=12, height=12,dot.size = 2)

test.MSstats$Volcano <- test.MSstats$ComparisonResult[!is.na(test.MSstats$ComparisonResult$pvalue),]
groupComparisonPlots(data=test.MSstats$Volcano, type="VolcanoPlot",
valid_comp_data <- test.MSstats$ComparisonResult[!is.na(test.MSstats$ComparisonResult$pvalue), ]
if (nrow(valid_comp_data[!duplicated(valid_comp_data$Protein),]) < 2) {
warning("Warning: Not enough proteins with valid p-values for comparison. Skipping groupComparisonPlots step!")
} else {
groupComparisonPlots(data=test.MSstats$ComparisonResult, type="ComparisonPlot",
width=12, height=12,dot.size = 2)

# Otherwise it fails since the behaviour is undefined
if (nrow(contrast_mat) > 1) {
groupComparisonPlots(data=test.MSstats$ComparisonResult, type="Heatmap",
groupComparisonPlots(data=valid_comp_data, type="VolcanoPlot",
width=12, height=12,dot.size = 2)

# Otherwise it fails since the behaviour is undefined
if (nrow(contrast_mat) > 1) {
groupComparisonPlots(data=test.MSstats$ComparisonResult, type="Heatmap",
width=12, height=12,dot.size = 2)
}
}

}
30 changes: 24 additions & 6 deletions bin/msstats_tmt.R
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,6 @@ if(typeof(reference_norm) == 'character'){
reference_norm <- char_to_boolean[reference_norm]
}

if (length(args)<12) {
# outputPrefix
args[12] <- './msstatsiso'
}

csv_input <- args[1]
contrast_str <- args[2]
control_str <- args[3]
Expand Down Expand Up @@ -246,5 +241,28 @@ if (l == 1) {
test.MSstatsTMT <- groupComparisonTMT(contrast.matrix=contrast_mat, data=processed.quant)

#TODO allow manual input (e.g. proteins of interest)
write.table(test.MSstatsTMT$ComparisonResult, file=paste0(args[12],"_comparisons.csv"), quote=FALSE, sep='\t', row.names = FALSE)
write.table(test.MSstatsTMT$ComparisonResult, file=paste0("msstatsiso_results.csv"), quote=FALSE, sep='\t', row.names = FALSE)

valid_comp_data <- test.MSstatsTMT$ComparisonResult[!is.na(test.MSstatsTMT$ComparisonResult$pvalue), ]

if (nrow(valid_comp_data[!duplicated(valid_comp_data$Protein),]) < 2) {
warning("Warning: Not enough proteins with valid p-values for comparison. Skipping groupComparisonPlots step!")
} else {
require(MSstats)
# BUG groupComparisonPlots function: re-run OpenMStoMSstatsTMTFormat
quant <- OpenMStoMSstatsTMTFormat(data, useUniquePeptide=useUniquePeptide, rmPSM_withfewMea_withinRun=rmPSM_withfewMea_withinRun,
rmProtein_with1Feature=rmProtein_with1Feature
)
groupComparisonPlots(data=test.MSstatsTMT$ComparisonResult, type="ComparisonPlot", width=12, height=12, dot.size = 2)

groupComparisonPlots(data=valid_comp_data, type="VolcanoPlot",
width=12, height=12, dot.size = 2)

# Otherwise it fails since the behavior is undefined
if (nrow(contrast_mat) > 1) {
groupComparisonPlots(data=test.MSstatsTMT$ComparisonResult, type="Heatmap",
width=12, height=12, dot.size = 2)
}
}

}
26 changes: 1 addition & 25 deletions bin/prepare_diann_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ def generate_cfg(ctx, enzyme, fix_mod, var_mod, precursor_tolerence, precursor_t
cut = enzyme_cut(enzyme)
unimod_database = UnimodDatabase()
fix_ptm, var_ptm = convert_mod(unimod_database, fix_mod, var_mod)
mass_acc, mass_acc_ms1 = mass_tolerence(precursor_tolerence, precursor_tolerence_unit, fragment_tolerence, fragment_tolerence_unit)
mass_acc = " --mass-acc " + str(mass_acc)
mass_acc_ms1 = " --mass-acc-ms1 " + str(mass_acc_ms1)

var_ptm_str = " --var-mod "
fix_ptm_str = " --fixed-mod "
Expand All @@ -36,11 +33,7 @@ def generate_cfg(ctx, enzyme, fix_mod, var_mod, precursor_tolerence, precursor_t
diann_var_ptm += (var_ptm_str + mod)

with open("diann_config.cfg", "w") as f:
f.write("--dir ./mzMLs --cut " + cut + diann_fix_ptm + diann_var_ptm + mass_acc + mass_acc_ms1 +
" --matrices --report-lib-info")

with open("library_config.cfg", "w") as f:
f.write("--cut " + cut + diann_fix_ptm + diann_var_ptm + " --gen-spec-lib --smart-profiling")
f.write("--cut " + cut + diann_fix_ptm + diann_var_ptm)

def convert_mod(unimod_database, fix_mod, var_mod):
pattern = re.compile("\((.*?)\)")
Expand Down Expand Up @@ -110,23 +103,6 @@ def enzyme_cut(enzyme):
cut = "--cut"
return cut

def mass_tolerence(prec, precursor_tolerence_unit, frag, fragment_tolerence_unit):
if precursor_tolerence_unit == "ppm":
ms1_tolerence = prec
else:
# Default 10 ppm
print("Warning: " + precursor_tolerence_unit + " unit not supported for DIA-NN. Default 10 ppm")
ms1_tolerence = 10

if fragment_tolerence_unit == "ppm":
ms2_tolerence = frag
else:
# Default 20 ppm
ms2_tolerence = 20
print("Warning: " + fragment_tolerence_unit + " unit not supported for DIA-NN. Default 20 ppm")

return ms1_tolerence, ms2_tolerence

cli.add_command(generate_cfg)

if __name__ == "__main__":
Expand Down
5 changes: 5 additions & 0 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ process {
// DIA-NN
withName: '.*:DIA:.*' {
ext.when = { !params.enable_conda }
publishDir = [
path: { "${params.outdir}/${task.process.tokenize(':')[-1].toLowerCase()}" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
}

}
Loading

0 comments on commit 7e13421

Please sign in to comment.