Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions SigProfilerMatrixGenerator/controllers/cli_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ def parse_arguments_sv_matrix_generator(args: List[str]) -> argparse.Namespace:
# Mandatory arguments
parser.add_argument("input_dir", help="The directory containing the input files.")
parser.add_argument("project", help="The name of the project.")
parser.add_argument(
"--plot",
type=str2bool,
nargs="?",
const=True,
default=False,
help="Integrates with SigProfilerPlotting to output matrix visualization. Default is False.",
)
parser.add_argument(
"output_dir", help="The directory where the output matrix will be stored."
)
Expand Down Expand Up @@ -245,6 +253,7 @@ def dispatch_sv_matrix_generator(self, user_args: List[str]) -> None:
input_dir=parsed_args.input_dir,
project=parsed_args.project,
output_dir=parsed_args.output_dir,
plot=parsed_args.plot,
)

def dispatch_cnv_matrix_generator(self, user_args: List[str]) -> None:
Expand Down
26 changes: 17 additions & 9 deletions SigProfilerMatrixGenerator/scripts/SVMatrixGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ def annotateBedpe(sv_bedpe):
return result


def generateSVMatrix(input_dir, project, output_dir, skip=False):
def generateSVMatrix(input_dir, project, output_dir, plot=True, skip=False):
# create output_dir if it does not yet exist
if not os.path.exists(output_dir):
os.makedirs(output_dir)
Expand Down Expand Up @@ -1017,18 +1017,26 @@ def generateSVMatrix(input_dir, project, output_dir, skip=False):

all_samples.append(result["sv_bedpe"])

if len(all_samples) < 1:
fout.write(
"Warning: unable to generate SV matrix, as all samples have 0 classified SVs"
)
return None

matrix = tsv2matrix(all_samples, project, output_dir)
out_file = os.path.join(output_dir, project + ".SV32.matrix.tsv")
matrix.to_csv(out_file, sep="\t")
print("Saved matrix to " + out_file)
sigPlt.plotSV(
matrix,
output_dir,
project,
savefig_format="pdf",
percentage=False,
aggregate=True,
)

if plot == True:
sigPlt.plotSV(
matrix,
output_dir,
project,
savefig_format="pdf",
percentage=False,
aggregate=True,
)

return matrix

Expand Down