1. ST prediction tutorial¶

Load packages¶

In [1]:
import numpy as np
import pandas as pd
import os
import subprocess
import sys
import pkg_resources
import time
import platform
import psutil
import pickle
from scipy.spatial import cKDTree
In [2]:
# Function to get system information
def get_system_info():
    print("\n--- System Information ---")
    print(f"Operating System: {platform.system()} {platform.release()} ({platform.version()})")
    print(f"Processor: {platform.processor()}")
    print(f"CPU Cores: {psutil.cpu_count(logical=False)} (Physical), {psutil.cpu_count(logical=True)} (Logical)")
    print(f"Total RAM: {psutil.virtual_memory().total / (1024**3):.2f} GB")

    # Check for GPU availability (if NVIDIA GPU is installed)
    try:
        gpu_info = subprocess.run("nvidia-smi --query-gpu=name --format=csv,noheader", 
                                  shell=True, capture_output=True, text=True, check=True)
        print(f"GPU: {gpu_info.stdout.strip()}")
    except subprocess.CalledProcessError:
        print("GPU: Not needed")
get_system_info()
--- System Information ---
Operating System: Linux 4.18.0-425.19.2.el8_7.x86_64 (#1 SMP Tue Apr 4 22:38:11 UTC 2023)
Processor: x86_64
CPU Cores: 28 (Physical), 56 (Logical)
Total RAM: 251.50 GB
GPU: Tesla K80

Define inputs¶

In [14]:
path2input = f'../output_data/smoothed_preds_tcga.pkl'
gene='ERBB2'
In [16]:
command = f"python ../scripts/3.SPAND/SPAND.py {path2input} {gene}"
print(command)
python ../scripts/3.SPAND/SPAND.py ../output_data/smoothed_preds_tcga.pkl ERBB2
In [17]:
# Measure execution time
start_time = time.time()

try:
    result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True, cwd=os.getcwd())
    print("Command Output:\n", result.stdout)
except subprocess.CalledProcessError as e:
    print("Error occurred:\n", e.stderr)

# Calculate elapsed time
end_time = time.time()
elapsed_time = end_time - start_time
print(f"Execution Time: {elapsed_time:.2f} seconds")
Command Output:
 ('WARNING: ', 305, ' is an island (no neighbors)')
1.6866524262923366

Execution Time: 10.26 seconds
In [ ]: