# -*- coding: utf-8 -*- """SiCM_PDAC_Gemcitabine Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/11q0FYW1s5t6bg-uUbnSEldUmBeauy5K2 """ #REMEMBER DOWNLOAD AS PY NOT IPYNB from sympy import solveset as solve from numpy import dot, exp import random import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt class PDAC(object): def __init__(self, non_numeric=False): self.non_numeric = non_numeric self.variablesList=["nutrients addition rate", "concentration of nutrients", "intratumoral pressure", "cell mobility rate", "imposed density of contrast in the vasculature", "transvascular mass transfer rate constant","rate of excretion of the contrast agent from blood", "injection rate of gemcitabine"] # end of Lee self.variablesDict={"nutrients addition rate" : 149.30208, "concentration of nutrients": 8.0, "intratumoral pressure": 76.0, "cell mobility rate": 1.0, "imposed density of contrast in the vasculature": 81.51, "transvascular mass transfer rate constant": 0.07,"rate of excretion of the contrast agent from blood": 0.02, "injection rate of gemcitabine": 10} #all but cell mobility rate and gemcitabine injection rate were calculated by me using the supplementary information from the models' papers #nutrients addition rate = + 2.07364 (40-8)+2.07364 *40=149.30208 mmHg (O2)/min #Defines variables to use later in multiple methods. def is_valid_menu_selection(self, tempInput): '''Checks to see if the menu selection inputted by the user is valid. If it is, it returns "is valid". Otherwise, it returns None.''' if(tempInput == '1'): return 'is valid' elif(tempInput == '2'): return 'is valid' else: return None def is_valid_variable_selection(self, parameter): '''Checks to see if the parameter selection inputted by the user is one of the choices to change. If it is, it returns "is valid". Otherwise, it returns None.''' if parameter in self.variablesList: tempValue = input('Insert new value: ') for k in self.variablesDict.keys(): if k == parameter: self.variablesDict[k] = float(tempValue) elif parameter=="2": return 'is valid' else: raise RuntimeError('Invalid selection!') def is_valid_parameter(self, parameter, non_numeric): '''Checks to see if the parameter inputted by the user is a number. If it is, it returns "is valid". Otherwise, it returns None.''' if(self.non_numeric == False): if('.' in parameter): countOfDecimals=0 for i in parameter: if i=='.': countOfDecimals+=1 if(countOfDecimals>1): return None else: parameter = parameter.replace('.','') if(parameter.isnumeric()==True): return 'is valid' else: return None def printInformation(self): '''Prints the background information board when the program is started.''' print('Would you like to read some background information as to how this program works?') #Prints options for the user to get instructions or not (in case they are returning user and do not want to read them again). print("") print("1-View information") print("2-Continue without background information") tempInput = input('Select an option: ') print("") #Checks if user's input is valid. if(self.is_valid_menu_selection(tempInput) == None): raise RuntimeError('Invalid menu selection! Please select either 1 or 2.') else: menuSelection = int(tempInput) #Prints background info if user asks for it. if menuSelection == 1: print('This program is a SiCM (Simple Computational Model) for treatment of PDAC with gemcitabine.') print('The aim of this simplified program is for traditional wet-lab medical scientists/oncologists') print('to understand how in sitio modeling can be better utilized for PDAC research') print('specifically with gemcitabine treatment. Overall, this program aims') print('to be a stepping stone towards utilizing more in sitio modeling to understand PDAC treatment') print('with gemcitabine in order to hopefully spark ideas for future wet-lab research to improve the efficacy') print('of this pre-existing treatment for PDAC, thus, improving the lives of PDAC patients.') def findDivergenceOperator(R, Sigma): DivergenceOperator=solve(Nabla**2*Sigma-R,Nabla) return(DivergenceOperator) #----------------------------------------------------------Beginning of Program------------------------------------------------------------------- def runProgram(self): #Prints a welcome board. print("******************************************************") print("* Welcome to SiCM for Treating PDAC with Gemcitabine *") print("******************************************************") menuSelection = 0 #Prints options for the user to start the program or quit the program and takes the user's input. print("") print("1-Start") print("2-Quit") tempInput = input('Select an option: ') print("") #Checks if user's input is valid. if(self.is_valid_menu_selection(tempInput) == None): raise RuntimeError('Invalid menu selection! Please select either 1 or 2.') else: menuSelection = int(tempInput) #While loop to be executed while the user is using the program while(menuSelection != 2): #Initializes all variables/#Resets all variables for when user wants to start again. Sigma = '' R='' Mu='' P='' Delta='' ivID='' Phi='' J='' #Asks user if they want background information printed for how the program works self.printInformation() #Executes while the user is playing the game. if(menuSelection == 1): #Takes user's parameter. print("") changeParametersSelection=0 print("This program utilizes a variety of user-changeable variables related to PDAC and gemcitabine.") print("") print("Of these (with default values) are: ") print('"nutrients addition rate" : 149.30208 mmHg(O2)/min, "concentration of nutrients": 8.0 mmHg(O2), "intratumoral pressure": 76.0 WN, "cell mobility rate": 1.0 (=normal mitosis rate), "imposed density of contrast in the vasculature": 81.51 HU, "transvascular mass transfer rate constant": 0.07 per second, "rate of excretion of the contrast agent from blood": 0.02 per second, "injection rate of gemcitabine": 10 mg/m2/min') print("") print("If you wish to change one or more variable(s), you can enter your new values one at a time.") while(changeParametersSelection != "2"): changeParametersSelection = input("Would you like to change a variable? Enter variable name or 2 for done.") self.is_valid_variable_selection(changeParametersSelection) #----------------------------------------------------------Beginning of Lee Model------------------------------------------------------------------- Sigma=float(self.variablesDict["concentration of nutrients"]) R=float(self.variablesDict["nutrients addition rate"]) #Carries out math with given parameters Nabla=(R/Sigma)**0.5 Mu=float(self.variablesDict["cell mobility rate"]) #found from mitosis rate since mitosis of cancerous cells very similar to proliferation for cancerous cells (i.e. cell mobility here) P=float(self.variablesDict["intratumoral pressure"]) # #Carries out math with given parameters Nu=-1*Mu*Nabla*P #Carries out math with given parameters LambdaP=dot(Nabla, Nu) LambdaA=(Mu*Sigma-LambdaP)/10000 print("Apoptotic rate of tumor cells is: ", (Mu*Sigma-LambdaP)/10000) #note defined earlier that mu ~= mitotic rate b and /1000 to get into similar units as Sup. Table 1 #----------------------------------------------------------Beginning of Haeno Model------------------------------------------------------------------- Grid=np.zeros((10,10)) #virtual primary tumor print("Initial virtual pancreas.") print(Grid) #see initial healthy pancreas countOf0=100 #count of T0 cells countOf1=0 #count of T1 cells countOf2=0 #count of T2 cells EVectorXandY=[] for k in range(0,7): #runs 7 times for approximating 7 years (see thesis paper) for i in range(0,10): #runs through x axis for j in range(0,10): #runs through y axis if Grid[i,j]==0: temp=random.randint(1,100000) #6300 or less changes for rate of epigenetic mutation change from type 0 to type 1 if temp<=6300: Grid[i,j]=1 EVectorXandY.append(i) EVectorXandY.append(j) countOf1+=1 countOf0-=1 elif Grid[i,j]==1: temp=random.randint(1, 100000) #63 or less changes for rate of metastasis from type 1 to type 2 if temp<=63: Grid[i,j]=2 EVectorXandY.append(i) EVectorXandY.append(j) countOf2+=1 countOf1-=1 print("Virtual pancreas years later.") print(Grid) #print new pancreas after 7 years print("T0 cells: ", countOf0*2000000, "T1 cells: ", countOf1*2000000, "T2 cells: ", countOf2*2000000) NumT1CellsWhichDieNaturally=countOf1*2000000*LambdaA NumT2CellsWhichDieNaturally=countOf2*2000000*LambdaA NumT1Cells=countOf1*2000000-NumT1CellsWhichDieNaturally NumT2Cells=countOf2*2000000-NumT2CellsWhichDieNaturally m=6.31*(10**(-5))#mu for Haeno q=6.31*(10**(-7)) #print("Expected metastatic sites are: ", countOf0*2000000*m*q+countOf1*2000000*q+countOf2*2000000) print("Expected metastatic sites are: ", countOf0*2000000*m*q+NumT1Cells*q+NumT2Cells) print('X and Y coordinates of expected metastatic sites are: ', EVectorXandY) #----------------------------------------------------------Beginning of Koay Model------------------------------------------------------------------- def model(Y, t): #RKoay=0.07 #in per seconds from Koay paper RKoay = self.variablesDict["transvascular mass transfer rate constant"]*(2.628*(10**6)) #in per month #Rc=0.02 #in per seconds from Koay paper Rc = self.variablesDict["rate of excretion of the contrast agent from blood"]*(2.628*(10**6)) #in per month YVMax=self.variablesDict["imposed density of contrast in the vasculature"] #From Koay paper dYdt=RKoay*(YVMax*exp(-1*Rc*t)-Y) return dYdt Y0=0 #given in Koay paper t=np.linspace(0,8.5,20) #because "Gemcitabine given as first-line treatment in three studies achieved a median survival of 7.4-8.3 months." Y=odeint(model,Y0,t) plt.plot(t,Y) plt.xlabel('Time') plt.ylabel('Y(t) - Density of Contrast in Tissue at t') #----------------------------------------------------------Beginning of Chen Model------------------------------------------------------------------- DiracDiffusion=0 functionEquation=0 #because diffusion is 0 at time 0 for i in range(0,60): #for 30 min of treatment and 30 min after to judge diffusion rate of gemcitabine if i<=30: gammaDrug = self.variablesDict["injection rate of gemcitabine"] else: gammaDrug=0 temp1=random.randint(0,10) temp2=random.randint(0,10) for j in EVectorXandY: if temp1 in EVectorXandY: if EVectorXandY[EVectorXandY.index(temp1)+1]==temp2: DiracDiffusion+=1 functionEquation+=(gammaDrug)*DiracDiffusion print('Diffusion rate of gemcitabine: ', functionEquation) #Not needed to be modeled but if wanted to... #y0=0 #assumed since no injection has occurred yet #t=np.linspace(0,30,20) #because gemcitabine dose is given for 30 min. #DrugDiffusionRate=model(y0,t) #plt.plot(t,DrugDiffusionRate) #plt.xlabel('Time') #plt.ylabel('Diffusion of Gemcitabine into Surroundings Over Time') #Original Attempt to fix with real values from table just to make it run without error #ydrug=1 #r=[1.0,3.0] #q=1 #rqt=[2.0,1.0] #Dt=10 #distanceBetweenInitialPositionAndPositionOfDiffusedDrugAtT=((rqt[0]-r[0])**2+(rqt[1]-r[1])**2)**0.5 #for q in range(Dt): # SummationForOverallDiffusionOfGem=ydrug*distanceBetweenInitialPositionAndPositionOfDiffusedDrugAtT # q+=1 #----------------------------------------------------------End of all Models------------------------------------------------------------------- print("") print("Thank you for using SiCM for PDAC with Gemcitabine!") #Original Exit Idea #When the program has been run to completion once, this prompts the user to quit or run again with new parameter values. #print("1-Yes") #print("2-No") #tempInput = input('Run again? ') #Checks to see if input is valid, and throws an errror if it is not. #if(self.is_valid_menu_selection(tempInput) == None): # raise RuntimeError('Invalid menu selection! Please select either 1 or 2.') #else: # menuSelection = int(tempInput) menuSelection=2 PDAC = PDAC() PDAC.runProgram()