# Model based on the Hansson et al. CPT:PsP 2013
# PKPD modeling of VEGF, sVEGFR-2, sVEGFR-3 and sKIT following sunitinib treatment in GIST
# The error model is different however and it assumes that data is not log transformed.


Hansson2013_data = dataObj{
	DECLARED_VARIABLES{
		DOSE :: dosingTarget
		LNVEGF_obs ::observation
		LNsVEGFR2_obs ::observation
		LNsVEGFR3_obs ::observation 
		LNsKIT_obs ::observation
	} 

   DATA_INPUT_VARIABLES{
      ID : { use is id }
      CYCL : { use is ignore }
      TIME : { use is idv }
      FLAG : { use is dvid } # 1=Dose ; 4=Tumor size (SLD); 5=VEGF ; 6=VEGFR2 ; 7=VEGFR3 ; 8=SKIT
      DVX : { use is ignore }
      DV : { use is dv, define = {5 in FLAG as LNVEGF_obs, 6 in FLAG as LNsVEGFR2_obs, 7 in FLAG as LNsVEGFR3_obs,
				8 in FLAG as LNsKIT_obs}  }
      AMT : { use is amt, variable=DOSE }
      PLA : { use is ignore } 
      CL : { use is covariate}
      EVID : { use is ignore }  # evid not supported in Product 4.1
   }
   
   SOURCE{
      srcFile : { file="BIOMARKER_simDATA.csv", inputFormat is nonmemFormat }
   }
}

Hansson2013_prior = priorObj {

	PRIOR_PARAMETERS{
		MU_CL=ln(0.1)
		MU_V=ln(8)
		MU_KA=ln(0.362)
		MU_TLAG=ln(1)
		MU_PPV_CL=ln(0.1)
		MU_PPV_V=ln(0.1)
		MU_PPV_KA=ln(0.1)
		MU_CORR_CL_V=ln(0.01)
		MU_RUV_PROP=ln(0.1)
		MU_RUV_ADD=ln(0.1)

		VAR_CL=1.5
		VAR_V=1
		VAR_KA=1.5
		VAR_TLAG=1.5
		VAR_PPV_CL=1.5
		VAR_PPV_V=1.5
		VAR_PPV_KA=1.5
		VAR_CORR_CL_V=2
		VAR_RUV_PROP=1.5
		VAR_RUV_ADD=1.5
	}
	
	PRIOR_VARIABLE_DEFINITION{


      POP_IMAX=1 
      POP_IC50=1 # Common IC50 for the four biomarkers which were found to be highly correlated

      #VEGF
      POP_BM0=59.7 # baseline VEGF
      POP_MRT=91 
      POP_HILL=3.31
      POP_TVSLP=0.035
                
      #sVEGFR-2
      POP_BM02=8670 # baseline sVEGFR-2
      POP_MRT2=554 
      POP_HILL2=1.54
      
      #sVEGFR-3
      POP_BM03=63900 # baseline sVEGFR-3
      POP_MRT3=401 

      #sKIT
      POP_BM0S=39200 # baseline sVEGFR-3
      POP_MRTS=2430
      
      #Residual Error
      POP_RES_VEGF_PROP=0.445 
      POP_RES_sVEGFR2_PROP=0.12 
      POP_RES_sVEGFR2_ADD=583
      POP_RES_sVEGFR3_PROP=0.22
      POP_RES_sKIT_PROP=0.224   

      OMEGA_BM0=0.252
      OMEGA_BM02=0.0369
      OMEGA_BM03=0.186
      OMEGA_BM0S=0.254
      
      OMEGA_MRT_VEGFs=0.060
      OMEGA_MRT_sKIT=0.0753

      OMEGA_IC50 =0.253
      OMEGA_IC502 =0.189
      OMEGA_IC503 =0.398
      OMEGA_IC50S =5.77

      OMEGA_TVSLP=2.95
      OMEGA_TVSLPS=3.01     
          
      SIGMA_RES_W=1
		
#		POP_CL ~ LogNormal2(meanLog=MU_CL, varLog = VAR_CL)
#		POP_V ~ LogNormal2(meanLog=MU_V, varLog = VAR_V)
#		POP_KA ~ LogNormal2(meanLog=MU_KA, varLog = VAR_KA)
#		POP_TLAG ~ LogNormal2(meanLog=MU_TLAG, varLog = VAR_TLAG)
#		PPV_CL ~ LogNormal2(meanLog=MU_PPV_CL, varLog = VAR_PPV_CL)
#		PPV_V ~ LogNormal2(meanLog=MU_PPV_V, varLog = VAR_PPV_V)
#		PPV_KA ~ LogNormal2(meanLog=MU_PPV_KA, varLog = VAR_PPV_KA)
#		CORR_CL_V ~ LogNormal2(meanLog=MU_CORR_CL_V, varLog = VAR_CORR_CL_V)
#		RUV_PROP ~ LogNormal2(meanLog=MU_RUV_PROP, varLog = VAR_RUV_PROP)
#		RUV_ADD ~ LogNormal2(meanLog=MU_RUV_ADD, varLog = VAR_RUV_ADD)
	}
}


Hansson2013_par = parObj{

   STRUCTURAL{

      POP_IMAX:{value=1, fix=true} 
      POP_IC50:{value=1, lo=0} # Common IC50 for the four biomarkers which were found to be highly correlated

      #VEGF
      POP_BM0:{value=59.7, lo=0} # baseline VEGF
      POP_MRT:{value=91, lo=0} 
      POP_HILL:{value=3.31, lo=0}
      POP_TVSLP:{value=0.035, lo=-0.06}
                
      #sVEGFR-2
      POP_BM02:{value=8670, lo=0} # baseline sVEGFR-2
      POP_MRT2:{value=554, lo=0} 
      POP_HILL2:{value=1.54, lo=0}
      
      #sVEGFR-3
      POP_BM03:{value=63900, lo=0} # baseline sVEGFR-3
      POP_MRT3:{value=401, lo=0} 

      #sKIT
      POP_BM0S:{value=39200, lo=0} # baseline sVEGFR-3
      POP_MRTS:{value=2430, lo=0}
      
      #Residual Error
      POP_RES_VEGF_PROP:{value=0.445, lo=0} 
      POP_RES_sVEGFR2_PROP:{value=0.12, lo=0} 
      POP_RES_sVEGFR2_ADD:{value=583, lo=0}
      POP_RES_sVEGFR3_PROP:{value=0.22, lo=0}
      POP_RES_sKIT_PROP:{value=0.224, lo=0}    
   }

   VARIABILITY{
      OMEGA_BM0:{value=0.252,type is var}
      OMEGA_BM02:{value=0.0369,type is var}
      OMEGA_BM03:{value=0.186,type is var}
      OMEGA_BM0S:{value=0.254,type is var}
      
      OMEGA_MRT_VEGFs:{value=0.060, type is var}
      OMEGA_MRT_sKIT:{value=0.0753, type is var}

      OMEGA_IC50 : { value=0.253, type is var }
      OMEGA_IC502 : { value=0.189, type is var }
      OMEGA_IC503 : { value=0.398, type is var }
      OMEGA_IC50S : { value=5.77, type is var }

      OMEGA_TVSLP:{value=2.95, type is var}
      OMEGA_TVSLPS:{value=3.01, type is var}     
          
      SIGMA_RES_W:{value=1 ,type is var, fix=true}
   }
}

### Model object
Hansson2013_mdl = mdlObj{
   IDV{ T }

   VARIABILITY_LEVELS{
	ID : { level=2, type is parameter }
	DV : { level=1 , type is observation}
   }
   COVARIATES{
	CL
   }

   STRUCTURAL_PARAMETERS{
      POP_IMAX
      POP_IC50 # Common IC50 for the four biomarkers which were found to be highly correlated

      #VEGF
      POP_BM0  # baseline VEGF
      POP_MRT 
      POP_HILL
      POP_TVSLP
                
      #sVEGFR-2
      POP_BM02
      POP_MRT2 
      POP_HILL2
      
      #sVEGFR-3
      POP_BM03
      POP_MRT3 

      #sKIT
      POP_BM0S
      POP_MRTS
      
      #Residual Error
      POP_RES_VEGF_PROP 
      POP_RES_sVEGFR2_ADD 
      POP_RES_sVEGFR2_PROP
      POP_RES_sVEGFR3_PROP
      POP_RES_sKIT_PROP       
   }# end STRUCTURAL_PARAMETERS

   VARIABILITY_PARAMETERS{
      OMEGA_BM0
      OMEGA_BM02
      OMEGA_BM03
      OMEGA_BM0S
      
      OMEGA_MRT_VEGFs
      OMEGA_MRT_sKIT
      
      OMEGA_IC50
      OMEGA_IC502
      OMEGA_IC503
      OMEGA_IC50S
              
      OMEGA_TVSLP
      OMEGA_TVSLPS     
      SIGMA_RES_W
   }# end VARIABILITY_PARAMETERS


   RANDOM_VARIABLE_DEFINITION(level=ID){
      eta_BM0 ~ Normal(mean=0, var=OMEGA_BM0)
      eta_BM02 ~ Normal(mean=0, var=OMEGA_BM02)
      eta_BM03 ~ Normal(mean=0, var=OMEGA_BM03)
      eta_BM0S ~ Normal(mean=0, var=OMEGA_BM0S)
      
      eta_MRT_VEGFs ~ Normal(mean=0, var=OMEGA_MRT_VEGFs)
      eta_MRT_sKIT ~ Normal(mean=0, var=OMEGA_MRT_sKIT)
   
      eta_IC50 ~ Normal(mean=0, var=OMEGA_IC50)
      eta_IC502 ~ Normal(mean=0, var=OMEGA_IC502)
      eta_IC503 ~ Normal(mean=0, var=OMEGA_IC503)
      eta_IC50S ~ Normal(mean=0, var=OMEGA_IC50S)
      
      eta_TVSLP ~ Normal(mean=0, var=OMEGA_TVSLP)
      eta_TVSLPS ~ Normal(mean=0, var=OMEGA_TVSLPS)   
   }# end RANDOM_VARIABLE_DEFINITION

   INDIVIDUAL_VARIABLES{
      BM0 : {type is linear, trans is ln, pop = POP_BM0, ranEff = eta_BM0}
      BM02 : {type is linear, trans is ln, pop = POP_BM02, ranEff = eta_BM02} 
      BM03 : {type is linear, trans is ln, pop = POP_BM03, ranEff = eta_BM03}
      BM0S : {type is linear, trans is ln, pop = POP_BM0S, ranEff = eta_BM0S} 
               
      IMAX1 = POP_IMAX
      IMAX2 = POP_IMAX
      IMAX3 = POP_IMAX
      IMAXS = POP_IMAX
     
      IC50  : {type is linear, trans is ln, pop = POP_IC50, ranEff = eta_IC50}
      IC502 : {type is linear, trans is ln, pop = POP_IC50, ranEff = eta_IC502} 
      IC503 : {type is linear, trans is ln, pop = POP_IC50, ranEff = eta_IC503}
      IC50S : {type is linear, trans is ln, pop = POP_IC50, ranEff = eta_IC50S} 
 
      HILL = POP_HILL
      HILL2 = POP_HILL2
     
      MRT1 : {type is linear, trans is ln, pop = POP_MRT, ranEff = eta_MRT_VEGFs} 
      MRT2 : {type is linear, trans is ln, pop = POP_MRT2, ranEff = eta_MRT_VEGFs} 
      MRT3 : {type is linear, trans is ln, pop = POP_MRT3, ranEff = eta_MRT_VEGFs}
      MRTS : {type is linear, trans is ln, pop = POP_MRTS, ranEff = eta_MRT_sKIT}
     
      TVSLP = POP_TVSLP/1000
      DPSLP : {type is linear,trans is ln, pop = TVSLP, ranEff = eta_TVSLP}
         
      TVSLPS = POP_TVSLP/1000
      DPSLPS : {type is linear,trans is ln, pop = TVSLPS, ranEff = eta_TVSLPS}
         
      # Derived parameters
      KOUT = 1/MRT1
      KOUT2 = 1/MRT2
      KOUT3 = 1/MRT3
      KOUTS = 1/MRTS

      KIN2 = BM02*KOUT2
      KIN3 = BM03*KOUT3
     
      }# end INDIVIDUAL_VARIABLES


   MODEL_PREDICTION{
      DOSE :: dosingVar
      AUC = DOSE/CL
      DP1 = BM0*(1+DPSLP*T)        # Linear disease progression model for VEGF
      DPS = BM0S*(1+DPSLPS*T)      # Linear disease progression model for SKIT

      KIN = DP1*KOUT
      KINS = DPS*KOUTS
       
    DEQ{
       EFF = IMAX1*AUC^HILL /(IC50^HILL+AUC^HILL)     # VEGF  : sigmoid Imax drug effect relationship
       EFF2 = IMAX2*AUC^HILL2/(IC502^HILL2+AUC^HILL2) # VEGFR2: sigmoid Imax drug effect relationship
       EFF3 = IMAX3*AUC/(IC503+AUC)                      # V EGFR3: Imax drug effect relationship
       EFFS = IMAXS*AUC/(IC50S+AUC)                      # SKIT  : Imax drug effect relationship
       
       VEGF : {deriv=KIN -KOUT*(1-EFF)*VEGF, init=BM0}
       sVEGFR2 : {deriv=KIN2*(1-EFF2)-KOUT2*sVEGFR2, init=BM02, wrt=T}
       sVEGFR3 : {deriv=KIN3*(1-EFF3)-KOUT3*sVEGFR3, init=BM03, wrt=T}
       sKIT : {deriv= KINS*(1-EFFS)-KOUTS*sKIT, init=BM0S, wrt=T}
    }
    
   }# end MODEL_PREDICTION

 
   RANDOM_VARIABLE_DEFINITION(level=DV){
      eps_RES_W ~ Normal(mean=0, var=SIGMA_RES_W)
   }

   OBSERVATION{
      LNVEGF_obs : {type is combinedError2, trans is ln, additive=0, proportional=POP_RES_VEGF_PROP, prediction=VEGF, eps=eps_RES_W}
      
      LNsVEGFR2_obs : {type is combinedError2, trans is ln, additive=POP_RES_sVEGFR2_ADD, proportional=POP_RES_sVEGFR2_PROP,
      		      			   prediction=sVEGFR2, eps=eps_RES_W}

      LNsVEGFR3_obs : {type is combinedError2, trans is ln, additive=0, proportional=POP_RES_sVEGFR3_PROP, prediction=sVEGFR3, eps=eps_RES_W}
  	  
      LNsKIT_obs : {type is combinedError2, trans is ln, additive=0, proportional=POP_RES_sKIT_PROP, prediction=sKIT, eps=eps_RES_W}
   }# end OBSERVATION

} # end of model object
       
       
Hansson2013_task = taskObj{
	ESTIMATE{ 
		set algo is mcmc
        TARGET_SETTINGS(target="BUGS"){
            set 
            nchains = 1,
            burnin = 1,
            niter = 1,
        #    parameters = "LAMBDA0_POP,LAMBDA1_POP,K1_POP,K2_POP,W0_POP,LAMBDA0,K2,CV",
         #    thinupdater=1,
          #  thinsamples=5, # uno dei due
#           odesolver="LSODA", #oppure LSODA
        #    dic="true",
        	winbugsgui="true" # oppure no
        }
}
}# end of task object

warfarin_PK_ODE_mog = mogObj {
	OBJECTS{
		Hansson2013_data : { type is dataObj}
		Hansson2013_mdl : { type is mdlObj }
		Hansson2013_prior : { type is priorObj }
		Hansson2013_task : { type is taskObj }
	}
}
