Commit f1bab812 authored by BeatriceTan's avatar BeatriceTan

Removed small errors.

parent acc6235f
*/.snakemake
.snakemake
rules/__pycache__/
*__pycache__*
rules/rubic_markers.smk
channels:
- conda-forge
- edurand
dependencies:
- matplotlib-venn =0.11.5
- pyensembl =1.1.0
from Rubic import get_seg_rubic
from Reports_new import ReportTools, ReportSegmentation
from Rubic import marker_file
from Reports import ReportTools, ReportSegmentation
import os.path
rule install_gistic:
......@@ -26,23 +26,34 @@ rule run_gistic:
wrapper:
"file:" + workflow.basedir + "/wrappers/GISTIC2"
rule seg_rubic:
"""Change segmentation file to use as input for RUBIC."""
#rule seg_rubic:
# """Change segmentation file to use as input for RUBIC."""
# input:
# "Input/Segments_tumor.txt"
# output:
# seg="RUBIC/Segmentation_file.txt",
# marker="RUBIC/Marker_file.txt"
# run:
# get_seg_rubic(input[0], output.seg, output.marker)
rule markers_rubic:
"""Make marker file to use as input for RUBIC."""
input:
"Input/Segments_tumor.txt"
output:
seg="RUBIC/Segmentation_file.txt",
marker="RUBIC/Marker_file.txt"
"Input/Markers.txt"
run:
get_seg_rubic(input[0], output.seg, output.marker)
marker_file(input[0], output[0])
rule run_rubic:
"""Run RUBIC for the tumor segmentation data."""
input:
seg="RUBIC/Segmentation_file.txt",
markers="RUBIC/Marker_file.txt"
seg="Input/Segments_tumor.txt",
markers="Input/Markers.txt"
output:
"RUBIC/"
out_gains="RUBIC/gains.txt",
out_losses="RUBIC/losses.txt",
out_plots="RUBIC/plots"
params:
fdr="0.25",
genefile="" #config["biomart_genes"]
......@@ -55,7 +66,7 @@ rule report_tools:
"""Report the differences in calls between GISTIC2 and RUBIC."""
input:
gistic="GISTIC/",
rubic="RUBIC/"
rubic="RUBIC/gains.txt"
output:
tools="Reports/Tools.txt",
genes_both="Reports/Genes_both.txt",
......
This diff is collapsed.
def marker_file(segment_file, marker_file):
"""Convert the segmentation file to format that rubic can take as input."""
positions = {}
with open(segment_file, 'r') as segments:
segments.readline()
for line in segments:
sample, chrom, start, end, num_probes, segment_mean = line.strip().split("\t")
pos = int(start) + int(int(end) - int(start) / 2) + 1
if chrom not in positions:
positions[chrom] = [pos, int(start), int(end)]
else:
positions[chrom] = positions[chrom] + [pos, int(start), int(end)]
print(positions)
with open(marker_file, 'w') as markers:
marker_nr = 1
for chrom in positions.keys():
all_unique_pos = sorted(list(set(positions[chrom]))) #only unique, sorted
print(all_unique_pos)
for pos in all_unique_pos:
marker_line = ["P000" + str(marker_nr), chrom, str(pos)]
markers.write("\t".join(marker_line) + "\n")
marker_nr += 1
def get_seg_rubic(segment_file, out_file, marker_file): #30,000 + 20,000x for markers middle? thus 60,000 bins
"""Convert the segmentation file to format that rubic can take as input."""
with open(marker_file, 'w') as markers:
......@@ -25,24 +48,6 @@ def get_seg_rubic(segment_file, out_file, marker_file): #30,000 + 20,000
marker_nr += 1
# positions = {}
# with open(marker_file, 'r') as markers:
# for line in markers:
# name, chrom, pos = line.strip().split("\t")
# if chrom not in positions:
# positions[chrom] = [pos]
# else:
# positions[chrom] = positions[chrom] + [pos]
# with
def markers_rubic(segment_file, out_file):
"""
Get marker file for running RUBIC
......
......@@ -4,12 +4,10 @@
# __license__ = "LUMC"
library(RUBIC)
print(snakemake@params[['genefile']])
all_genes <- system.file("extdata", "genes.tsv", package="RUBIC")
#all_genes <- if (snakemake@params[["genefile"]] == "") system.file("extdata", "genes.tsv", package="RUBIC") else snakemake@params[["genefile"]]
all_genes <- if (snakemake@params[["genefile"]] == "") system.file("extdata", "genes.tsv", package="RUBIC") else snakemake@params[["genefile"]]
fdr <- if (snakemake@params[["fdr"]] == "") 0.25 else snakemake@params[["fdr"]]
print(fdr)
rbc <- rubic(fdr, snakemake@input[["seg"]], snakemake@input[["markers"]], genes=all_genes)
print("rbc ready")
rbc$save.focal.gains(snakemake@output[["out_gains"]])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment