Skip to content

Commit

Permalink
Merge pull request #51 from mskcc/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
nikhil authored Jul 30, 2024
2 parents d82ec09 + 7f820a8 commit ab09ea5
Show file tree
Hide file tree
Showing 15 changed files with 378 additions and 203 deletions.
38 changes: 19 additions & 19 deletions modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
"modules": {
"msk": {
"neoantigenediting/aligntoiedb": {
"branch": "neoantigen",
"git_sha": "14ae2b3db25701828835e7145cee14dfdaddf180",
"branch": "develop",
"git_sha": "cac9c047e374ee259fb612ba5816e7e6aae6b86f",
"installed_by": ["neoantigen_editing"]
},
"neoantigenediting/computefitness": {
"branch": "neoantigen",
"branch": "develop",
"git_sha": "1f65c2ecdc5010549055ff7f4e6b8bccee48d4ae",
"installed_by": ["neoantigen_editing"]
},
"neoantigenutils/formatnetmhcpan": {
"branch": "neoantigen",
"git_sha": "fceccd3f96fec678849bb9bc0c04e53d9965f973",
"branch": "develop",
"git_sha": "c5d1252252e15555abcc82ea537cebeb281a1856",
"installed_by": ["netmhcstabandpan"]
},
"neoantigenutils/generatehlastring": {
"branch": "neoantigen",
"branch": "develop",
"git_sha": "33f0bd33095fa15016ee24f4fb4d61e896dbb970",
"installed_by": ["netmhcstabandpan"]
},
"neoantigenutils/generatemutfasta": {
"branch": "neoantigen",
"branch": "develop",
"git_sha": "bb7975c796ab9a2d7a45ef733a6a226a0f5ad74a",
"installed_by": ["netmhcstabandpan"]
},
Expand All @@ -36,32 +36,32 @@
"installed_by": ["modules"]
},
"netmhcpan": {
"branch": "neoantigen",
"git_sha": "33f0bd33095fa15016ee24f4fb4d61e896dbb970",
"branch": "develop",
"git_sha": "503abeb67260f060d8228221b07d743aa4180345",
"installed_by": ["modules", "netmhcstabandpan"]
},
"netmhcstabpan": {
"branch": "neoantigen",
"git_sha": "33f0bd33095fa15016ee24f4fb4d61e896dbb970",
"branch": "develop",
"git_sha": "c1a473f8bc08f778269a36ab62d5adf24357225f",
"installed_by": ["modules", "netmhcstabandpan"]
},
"phylowgs/createinput": {
"branch": "neoantigen",
"branch": "develop",
"git_sha": "b031249dcf4279606c25e626da2a628756e75e8a",
"installed_by": ["phylowgs"]
},
"phylowgs/multievolve": {
"branch": "neoantigen",
"branch": "develop",
"git_sha": "535662d391a3533dea3b11c462c14799227e08b2",
"installed_by": ["phylowgs"]
},
"phylowgs/parsecnvs": {
"branch": "neoantigen",
"branch": "develop",
"git_sha": "8471691d7c29bc2f5f4fb92279c94fb2640b6c38",
"installed_by": ["phylowgs"]
},
"phylowgs/writeresults": {
"branch": "neoantigen",
"branch": "develop",
"git_sha": "6d27f08bf649e8680ace321d3127dcdf0e210973",
"installed_by": ["phylowgs"]
}
Expand All @@ -70,17 +70,17 @@
"subworkflows": {
"msk": {
"neoantigen_editing": {
"branch": "neoantigen",
"branch": "develop",
"git_sha": "56a628201401866096d6307b9e8c690c5eb46ac2",
"installed_by": ["subworkflows"]
},
"netmhcstabandpan": {
"branch": "neoantigen",
"git_sha": "1b7ac020798572be26402a72dd9c1a22ce849a63",
"branch": "develop",
"git_sha": "d60211568e3709e9284bc06eef938e361d474d08",
"installed_by": ["subworkflows"]
},
"phylowgs": {
"branch": "neoantigen",
"branch": "develop",
"git_sha": "a5d61394af346f21ee2eb7ecfd97ab25bdbd1d0e",
"installed_by": ["subworkflows"]
}
Expand Down
2 changes: 1 addition & 1 deletion modules/msk/neoantigenediting/aligntoiedb/meta.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "neoantigenediting_aligntoiedb"
description: Align neoantigens to the IEDB resource
description: Align neoantigens to the IEDB file
keywords:
- neoantigenediting
- neoantigens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,20 @@ def load_blosum62_mat():
* -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 1
"""
amino_acids = "ACDEFGHIKLMNPQRSTVWY"
blosum62_mat_str_list = [l.split() for l in raw_blosum62_mat_str.strip().split("\n")]
blosum62_mat_str_list = [
l.split() for l in raw_blosum62_mat_str.strip().split("\n")
]
blosum_aa_order = [blosum62_mat_str_list[0].index(aa) for aa in amino_acids]

blosum62_mat = np.zeros((len(amino_acids), len(amino_acids)))
for i, bl_ind in enumerate(blosum_aa_order):
blosum62_mat[i] = np.array([int(x) for x in blosum62_mat_str_list[bl_ind + 1][1:]])[blosum_aa_order]
blosum62_mat[i] = np.array(
[int(x) for x in blosum62_mat_str_list[bl_ind + 1][1:]]
)[blosum_aa_order]
blosum62 = {
(aaA, aaB): blosum62_mat[i, j] for i, aaA in enumerate(amino_acids) for j, aaB in enumerate(amino_acids)
(aaA, aaB): blosum62_mat[i, j]
for i, aaA in enumerate(amino_acids)
for j, aaB in enumerate(amino_acids)
}
return blosum62

Expand Down Expand Up @@ -226,7 +232,9 @@ def load_epitopes(iedbfasta):
pjson = json.load(f)
patient = pjson["patient"]
neoantigens = pjson["neoantigens"]
peptides = set([("_".join(neo["id"].split("_")[:-1]), neo["sequence"]) for neo in neoantigens])
peptides = set(
[("_".join(neo["id"].split("_")[:-1]), neo["sequence"]) for neo in neoantigens]
)
pepseq2pepid = defaultdict(set)
for pep_id, pep_seq in peptides:
pepseq2pepid[pep_seq].add(pep_id)
Expand All @@ -251,5 +259,7 @@ def load_epitopes(iedbfasta):
"Alignment_score",
]
else:
aln_data = pd.DataFrame(columns=["Peptide_ID", "Peptide", "Epitope_ID", "Alignment_score"])
aln_data = pd.DataFrame(
columns=["Peptide_ID", "Peptide", "Epitope_ID", "Alignment_score"]
)
aln_data.to_csv("iedb_alignments_" + patient + ".txt", sep="\t", index=False)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import os


# %
class EpitopeDistance(object):
"""Base class for epitope crossreactivity.
Expand Down Expand Up @@ -39,7 +38,9 @@ class EpitopeDistance(object):

def __init__(
self,
model_file=os.path.join(os.path.dirname(__file__), "distance_data", "epitope_distance_model_parameters.json"),
model_file=os.path.join(
os.path.dirname(__file__), "distance_data", "epitope_distance_model_parameters.json"
),
amino_acids="ACDEFGHIKLMNPQRSTVWY",
):
"""Initialize class and compute M_ab."""
Expand Down Expand Up @@ -75,5 +76,11 @@ def epitope_dist(self, epiA, epiB):
"""

return sum(
[self.d_i[i] * self.M_ab[self.amino_acid_dict[epiA[i]], self.amino_acid_dict[epiB[i]]] for i in range(9)]
[
self.d_i[i]
* self.M_ab[
self.amino_acid_dict[epiA[i]], self.amino_acid_dict[epiB[i]]
]
for i in range(9)
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def fill_up_clone_neoantigens(tree, mut2neo):
while len(nodes) > 0:
node = nodes[0]
nodes = nodes[1:]
node["neoantigens"] = [neo["id"] for mid in node["all_mutations"] for neo in mut2neo[mid]]
node["neoantigens"] = [
neo["id"] for mid in node["all_mutations"] for neo in mut2neo[mid]
]
node["neoantigen_load"] = len(node["neoantigens"])
node["NA_Mut"] = sum([len(mut2neo[mid]) > 0 for mid in node["all_mutations"]])
if "children" in node:
Expand Down Expand Up @@ -157,7 +159,9 @@ def compute_effective_sample_size(sample_json):
for clone_muts, X in zip(clone_muts_list, freqs):
for mid in clone_muts:
mut_freqs[mid].append(X)
avev = np.mean([np.var(mut_freqs[mid]) if mut_freqs[mid] else 0 for mid in mut_freqs])
avev = np.mean(
[np.var(mut_freqs[mid]) if mut_freqs[mid] else 0 for mid in mut_freqs]
)
n = 1 / avev
return n

Expand Down
6 changes: 3 additions & 3 deletions modules/msk/neoantigenutils/formatnetmhcpan/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ process NEOANTIGENUTILS_FORMATNETMHCPAN {
stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def netmhcOutputType = meta.typeMut ? "MUT": "WT"
def netmhcOutputFrom = meta.fromStab ? "STAB": "PAN"
"""
touch ${prefix}.MUT.tsv
touch ${prefix}.WT.tsv
touch ${prefix}.${netmhcOutputType}.${netmhcOutputFrom}.tsv
cat <<-END_VERSIONS > versions.yml
"${task.process}":
formatNetmhcpanOutput: \$(echo \$(format_netmhcpan_output.py -v))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,27 @@ def netMHCpan_out_reformat(netMHCpanoutput, mut, stab, prefix):

def parse_args():
parser = argparse.ArgumentParser(description="Process input files and parameters")
parser.add_argument("--netMHCpan_output", required=True, help="Path to netMHC output")
parser.add_argument(
"--netMHCpan_output", required=True, help="Path to netMHC output"
)
parser.add_argument("--type_MUT", action="store_true", help="Output is a MUT type")
parser.add_argument(
"--from_STAB",
action="store_true",
help="Output is from netmhcstab",
)
parser.add_argument("--id", required=True, help="Prefix to label the output")
parser.add_argument("-v", "--version", action="version", version="%(prog)s {}".format(VERSION))
parser.add_argument(
"-v", "--version", action="version", version="%(prog)s {}".format(VERSION)
)

return parser.parse_args()


def main(args):
netMHCpan_out_reformat(args.netMHCpan_output, args.type_MUT, args.from_STAB, args.id)
netMHCpan_out_reformat(
args.netMHCpan_output, args.type_MUT, args.from_STAB, args.id
)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-13T12:57:40.919561"
"timestamp": "2024-07-30T13:46:27.878268"
},
"neoantigenutils_formatnetmhcpan - output(MUT,netmhcpan) - tsv - stub": {
"content": [
Expand All @@ -46,10 +42,7 @@
"typeMut": true,
"fromStab": false
},
[
"test.MUT.tsv:md5,d41d8cd98f00b204e9800998ecf8427e",
"test.WT.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
"test.MUT.PAN.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
Expand All @@ -62,22 +55,15 @@
"typeMut": true,
"fromStab": false
},
[
"test.MUT.tsv:md5,d41d8cd98f00b204e9800998ecf8427e",
"test.WT.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
"test.MUT.PAN.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,2c02f5f3103ee1532c27f7f3b873a578"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-13T12:58:01.264912"
"timestamp": "2024-07-30T13:47:05.72509"
},
"neoantigenutils_formatnetmhcpan - output(WT,netmhcpan) - tsv": {
"content": [
Expand Down Expand Up @@ -110,11 +96,7 @@
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-13T12:57:46.381516"
"timestamp": "2024-07-30T13:46:37.183992"
},
"neoantigenutils_formatnetmhcpan - output(MUT,netmhcpanstab) - tsv": {
"content": [
Expand Down Expand Up @@ -147,11 +129,7 @@
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-13T12:57:51.691253"
"timestamp": "2024-07-30T13:46:47.110076"
},
"neoantigenutils_formatnetmhcpan - output(WT,netmhcpanstab) - tsv": {
"content": [
Expand Down Expand Up @@ -184,10 +162,6 @@
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-13T12:57:56.882818"
"timestamp": "2024-07-30T13:46:56.841519"
}
}
Loading

0 comments on commit ab09ea5

Please sign in to comment.