Exemplo n.º 1
0
        sys.exit(
            "ERROR: You already used this name for a previous run. \nUse a different name!"
        )
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#~~~~~~~~~~~~~~~~~~~Preliminary steps and transformation~~~~~~~~~~~~~~~~~~~~~~#
#Concatenate#
no_arc, input_files = concatenate_fcs(
    input_dir)  #Does sanity check of files in input

#Downsampling#
#Test lenght of input files -> Go with minimun denominator -> select, at random,
# that number of cells from other files
if no_arc["file_origin"].value_counts().size > 1:
    downs_inputs = yes_or_NO(
        "Multiple input files detected. Would you like to donwsample the number of cells?",
        default="YES")
    if downs_inputs:
        print("Downsampling taking place. Check output folder for more info")
        print(no_arc["file_origin"].value_counts())
        no_arc = downsample_data(no_arc, info_run, output_dir)
        print(no_arc["file_origin"].value_counts())
    else:
        print("Multiple input files; no downsampling")
else:
    print("Only one input file detected; no downsampling")

#Transformation#
#Literature recommends cofactor of 5 for cytof data
arc, cols = arcsinh_transf(cofactor, no_arc)
#Storing marker columns for later use below
Exemplo n.º 2
0
from aux.aux_functions import yes_or_NO

#2 options for the PCA plots:
    #Either run basic PCA on R and plot in shiny app (less graphical customisation, simpler plots)
    #Leverage PCA shiny apps. 
        #PCAshiny from Factoshiny -> Very basic
        #Interactive PCA Explorer

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I/O~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
aux_dir = os.path.dirname(os.path.abspath(__file__))+"/aux"

input_dir = f"{base_dir}/Analysis/Vis_PCA"
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~User Input~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
emd = yes_or_NO("Perform PCA on the EMD scores?", default="YES")
dremi = yes_or_NO("Perform PCA on the DREMI scores?")
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Execute shiny Apps~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#Input files should have either emd or dremi on their name
if emd==True and dremi==False:
    emd_file = []
    for file in os.listdir(input_dir):
        if file.endswith(".txt"):
            if "emd" in file.lower():
                emd_file.append(file)
    if len(emd_file) != 1:
            sys.exit("ERROR: Please have only ONE .txt file with 'emd' in its name!")
    emd_file = f"{input_dir}/{emd_file[0]}"
Exemplo n.º 3
0
info_run = input("Write EMD info run (using no spaces!): ")
if len(info_run) == 0:
    print("No info run given. Saving results in UNNAMED")
    info_run = "UNNAMED"
if os.path.isdir(f"{output_dir}/{info_run}") == False:
    os.makedirs(f"{output_dir}/{info_run}")
else:
    if info_run != "UNNAMED":
        sys.exit(
            "ERROR: You already used this name for a previous run. \nUse a different name!"
        )
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~User Input~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
filter_markers = yes_or_NO(
    "Do you want to filter out markers from the panel? (If so please provide .csv file)",
    default="YES")

print(
    "In EMD, the individual Variable distributions are compared against a reference distribution"
)
print(
    "By default concatenated input files will be used as the reference distribution."
)
user_defined_denominator = yes_or_NO(
    "Would you like to define your own reference instead?")
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#~~~~~~~~~~~~~~~~~~~~~Preparatory steps and transformation~~~~~~~~~~~~~~~~~~~~#
# set up the files to be analysed (compare_from and compare_to)
# denominator can be concatenated input files or the user-defined txt file
Exemplo n.º 4
0
output_dir = f"{base_dir}/Utils_Data/output/{folder_name}"

###~Sanity check for contents~###
filelist = [f for f in os.listdir(input_dir) if f.endswith(".txt")]
if len(filelist) == 0:
    sys.exit(f"ERROR: There are no files in {input_dir}!")
#Check the files found in the directory:
print("Input files:")
for i in filelist:
    print(i)

###~Co-factor~###
#Check if user wants to filter the markers based on a .csv marker file
cofactor = 5
user_cofactor = yes_or_NO(
    "Using alpha=5 for the transformation. Would you like to change this value?"
)
if user_cofactor:
    cofactor = int(input("Enter the new alpha to use (5=default): "))
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Perform transformation~~~~~~~~~~~~~~~~~~~~~~~~~~#
#Identify marker columns
for input_file in filelist:
    markers = []
    dataset = pd.read_csv(f"{input_dir}/{input_file}", sep='\t')
    print("Data read!")
    markers.append([x for x in dataset.columns if x[0].isdigit()])
    print("Processed columns")
    for i in markers:
        print("Columns identified as markers: \n", i)
Exemplo n.º 5
0
import subprocess
import os
import sys
from aux.aux_functions import yes_or_NO
#Import yes or no question to choose the different plotings
#Run the separate R shiny apps accordingly
#Simultaneous emd and DREMI should both be possible since the ports are random

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I/O~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
aux_dir = os.path.dirname(os.path.abspath(__file__)) + "/aux"

input_dir = f"{base_dir}/Analysis/Vis_Heatmap"
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~User Input~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
emd = yes_or_NO("Plot EMD scores on a heatmap?", default="YES")
dremi = yes_or_NO("Plot DREMI scores on a heatmap?")
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Execute shiny Apps~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#Input files should have either emd or dremi on their name.
if emd == True and dremi == False:
    emd_file = []
    for file in os.listdir(input_dir):
        if file.endswith(".txt"):
            if "emd" in file.lower():
                emd_file.append(file)
    if len(emd_file) != 1:
        sys.exit(
            "ERROR: Please have only ONE .txt file with 'emd' in its name!")
    emd_file = f"{input_dir}/{emd_file[0]}"