39.安装PH5\PH7

本文详细介绍了PHP5和PHP7的安装过程,包括下载、配置、编译和安装步骤,还提及了安装过程中可能遇到的报错及解决方法。同时说明了如何查看PHP和Apache加载的模块,以及如何在PHP5和PHP7之间进行切换,通过修改Apache配置文件实现。

11.10/11.11/11.12 安装PHP5

11.13 安装PHP7

php中mysql,mysqli,mysqlnd,pdo到底是什么 

http://blog.youkuaiyun.com/u013785951/article/details/60876816

查看编译参数 

http://ask.apelearn.com/question/1295

 

 

 

 

11.10/11.11/11.12 安装PHP5:

 

 

PHP官网www.php.net

当前主流版本为5.6/7.1

有些过老的版本可能不兼容7版本。7的性能比5有很大的提升

cd /usr/local/src/

wget http://cn2.php.net/distributions/php-5.6.32.tar.gz

tar zxf php-5.6.32.tar.gz

cd php-5.6.32

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

--prefix=/usr/local/php 指定安装目录

--with-apxs2 apxs2是Apache的一种工具,可以自动的把扩展的模块放到Apache的目录里,就是在我们用httpd -M的时候可以加载出来。阿鑫在做的时候,修改了他的路径(find一下apxs2,查到目录,修改一下就可以了)

--with-config-file-path=/usr/local/php/etc 指定php的配置文件

--with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config 指定这三种mysql不同的库。相当于php与mysql相互通信的驱动,所以是定义mysql的函数或者驱动的

后面的都是指定php的模块的

make && make install

cp php.ini-production /usr/local/php/etc/php.ini 我们指定了他的配置文件,要拷贝到那里去( --with-config-file-path).。如果是开发环境就用 php.ini-development,php.ini-production用于生产环境

 

知识点:

/usr/local/php/bin/ PHP的核心文件

/usr/local/apache2.4/modules/libphp5.so 这是我们安装php5的模块。我们需要的

/usr/local/php/bin/ -m 查看php加载的模块有哪些(静态的)。是可以扩展的,增加.so的文件

/usr/local/apache2.4/bin/httpd -M 可以查看Apache的模块。最后就是我们安装的php5的模块

php作为Apache的扩展模块存在的。也就是说Apache需要借助php module,也就是借助这个.so的文件

vim /usr/local/apache2.4/conf/httpd.conf 可以查看Apache的模块。php也在其中

 

实例:

[root@localhost]# cd /usr/local/src

[root@localhost src]# wget http://cn2.php.net/distributions/php-5.6.32.tar.gz

[root@localhost src]#tar zxf php-5.6.32.tar.gz

[root@localhost src]# cd php-5.6.32/

[root@localhost php-5.6.32]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

以下的几个报错,安装PH5.6.32

1.configure: error: xml2-config not found. Please check your libxml2 installation.

#yum install -y libxml2-devel

2.configure: error: Cannot find OpenSSL's <evp.h>
#yum install -y openssl-devel

3.configure: error: Please reinstall the BZip2 distribution

#yum install -y bzip2 bzip2-devel

4.configure: error: jpeglib.h not found.
#yum -y install libjpeg-devel

5.configure: error: png.h not found.

#yum install -y libpng libpng-devel

6.configure: error: freetype-config not found.

#yum install -y freetype freetype-devel

7.configure: error: mcrypt.h not found. Please reinstall libmcrypt.

#yum install -y epel-release

#yum install -y libmcrypt-devel

编译完成

Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands

安装PH7提示报错

1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
 

#yum install -y perl* 

​#yum install -y httpd-devel

#find / -name apxs  得到的路径是:/usr/sbin/apxs

于是修改--with-apsx2=/usr/sbin/apxs指定到正确路径

还有n个报错,都是缺少一些库。安装就好了

[root@localhost php-5.6.32]# echo $? 直到成功。configure成功

0

[root@localhost php-5.6.32]# make 开始make

xt/standard/crypt_blowfish.lo ext/standard/crypt_sha512.lo ext/standard/crypt_sha256.lo ext/standard/php_crypt_r.lo ext/standard/array.lo ext/standard/base64.lo ext/standard/basic_functions.lo ext/standard/browscap.lo ext/standard/crc32.lo ext/standard/crypt.lo ext/standard/cyr_convert.lo ext/standard/datetime.lo ext/standard/dir.lo ext/standard/dl.lo ext/standard/dns.lo ext/standard/exec.lo ext/standard/file.lo ext/standard/filestat.lo ext/standard/flock_compat.lo ext/standard/formatted_print.lo ext/standard/fsock.lo ext/standard/head.lo ext/standard/html.lo ext/standard/image.lo ext/standard/info.lo ext/standard/iptc.lo ext/standard/lcg.lo ext/standard/link.lo ext/standard/mail.lo ext/standard/math.lo ext/standard/md5.lo ext/standard/metaphone.lo ext/standard/microtime.lo ext/standard/pack.lo ext/standard/pageinfo.lo ext/standard/quot_print.lo ext/standard/rand.lo ext/standard/soundex.lo ext/standard/string.lo ext/standard/scanf.lo ext/standard/syslog.lo ext/standard/type.lo ext/standard/uniqid.lo ext/standard/url.lo ext/standard/var.lo ext/standard/versioning.lo ext/standard/assert.lo ext/standard/strnatcmp.lo ext/standard/levenshtein.lo ext/standard/incomplete_class.lo ext/standard/url_scanner_ex.lo ext/standard/ftp_fopen_wrapper.lo ext/standard/http_fopen_wrapper.lo ext/standard/php_fopen_wrapper.lo ext/standard/credits.lo ext/standard/css.lo ext/standard/var_unserializer.lo ext/standard/ftok.lo ext/standard/sha1.lo ext/standard/user_filters.lo ext/standard/uuencode.lo ext/standard/filters.lo ext/standard/proc_open.lo ext/standard/streamsfuncs.lo ext/standard/http.lo ext/standard/password.lo ext/tokenizer/tokenizer.lo ext/tokenizer/tokenizer_data.lo ext/xml/xml.lo ext/xml/compat.lo ext/xmlreader/php_xmlreader.lo ext/xmlwriter/php_xmlwriter.lo TSRM/TSRM.lo TSRM/tsrm_strtok_r.lo main/main.lo main/snprintf.lo main/spprintf.lo main/php_sprintf.lo main/fopen_wrappers.lo main/alloca.lo main/php_scandir.lo main/php_ini.lo main/SAPI.lo main/rfc1867.lo main/php_content_types.lo main/strlcpy.lo main/strlcat.lo main/mergesort.lo main/reentrancy.lo main/php_variables.lo main/php_ticks.lo main/network.lo main/php_open_temporary_file.lo main/output.lo main/getopt.lo main/streams/streams.lo main/streams/cast.lo main/streams/memory.lo main/streams/filter.lo main/streams/plain_wrapper.lo main/streams/userspace.lo main/streams/transports.lo main/streams/xp_socket.lo main/streams/mmap.lo main/streams/glob_wrapper.lo Zend/zend_language_parser.lo Zend/zend_language_scanner.lo Zend/zend_ini_parser.lo Zend/zend_ini_scanner.lo Zend/zend_alloc.lo Zend/zend_compile.lo Zend/zend_constants.lo Zend/zend_dynamic_array.lo Zend/zend_dtrace.lo Zend/zend_execute_API.lo Zend/zend_highlight.lo Zend/zend_llist.lo Zend/zend_vm_opcodes.lo Zend/zend_opcode.lo Zend/zend_operators.lo Zend/zend_ptr_stack.lo Zend/zend_stack.lo Zend/zend_variables.lo Zend/zend.lo Zend/zend_API.lo Zend/zend_extensions.lo Zend/zend_hash.lo Zend/zend_list.lo Zend/zend_indent.lo Zend/zend_builtin_functions.lo Zend/zend_sprintf.lo Zend/zend_ini.lo Zend/zend_qsort.lo Zend/zend_multibyte.lo Zend/zend_ts_hash.lo Zend/zend_stream.lo Zend/zend_iterators.lo Zend/zend_interfaces.lo Zend/zend_exceptions.lo Zend/zend_strtod.lo Zend/zend_gc.lo Zend/zend_closures.lo Zend/zend_float.lo Zend/zend_string.lo Zend/zend_signal.lo Zend/zend_generators.lo Zend/zend_virtual_cwd.lo Zend/zend_ast.lo Zend/zend_objects.lo Zend/zend_object_handlers.lo Zend/zend_objects_API.lo Zend/zend_default_classes.lo Zend/zend_execute.lo main/internal_functions_cli.lo sapi/cgi/cgi_main.lo sapi/cgi/fastcgi.lo -lcrypt -lresolv -lcrypt -lrt -lmysqlclient_r -lmcrypt -lpng -lz -ljpeg -lbz2 -lz -lrt -lm -ldl -lnsl -lxml2 -lz -lm -ldl -lssl -lcrypto -lxml2 -lz -lm -ldl -lfreetype -lmysqlclient -lm -lrt -ldl -lmysqlclient -lm -lrt -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lcrypt -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lcrypt  -o sapi/cgi/php-cgi
Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
clicommand.inc
directorytreeiterator.inc
invertedregexiterator.inc
directorygraphiterator.inc
pharcommand.inc
phar.inc

Build complete.
Don't forget to run 'make test'.

[root@localhost php-5.6.32]# echo $? 查看是否成功

0

[root@localhost php-5.6.32]# make install

Installing PEAR environment:      /usr/local/php/lib/php/
[PEAR] Archive_Tar    - installed: 1.4.3
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util       - installed: 1.4.2
[PEAR] PEAR           - installed: 1.10.5
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/usr/local/src/php-5.6.32/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:           /usr/local/php/include/php/ext/pdo/

[root@localhost php-5.6.32]# echo $? 查看是否成功

0

[root@localhost php-5.6.32]# cp php.ini-production /usr/local/php/etc/php.ini

 

 

!!阿鑫在./configure的时候,因为--with exps的路径写错了。阿鑫的电脑路径是apache2,跟着阿铭老师写了2.4结果导致不成功。这点需要注意

 

 

 

----------------------------------------------------------------------------------------------------------------------------------------------------

 

 

11.13 安装PHP7:

 

 

 

 

cd /usr/local/src/

wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2

tar xjvf php-7.1.6.tar.bz2 //tar -xvf axin.tar 解包,后面跟打包名

tar zxf php-7.1.6.tar.bz2 (报错,z : 表示 tar 包是被 gzip 压缩过的,所以解压时需要用 gunzip 解压

cd php-7.1.6

./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

Thank you for using PHP.

config.status: creating php7.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands

make

Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
directorytreeiterator.inc
directorygraphiterator.inc
pharcommand.inc
clicommand.inc
invertedregexiterator.inc
phar.inc

Build complete.
Don't forget to run 'make test'.

&& make install

Wrote PEAR system config file at: /usr/local/php7/etc/pear.conf
You may want to add: /usr/local/php7/lib/php to your php.ini include_path
/usr/local/src/php-7.1.6/build/shtool install -c ext/phar/phar.phar /usr/local/php7/bin
ln -s -f phar.phar /usr/local/php7/bin/phar
Installing PDO headers:           /usr/local/php7/include/php/ext/pdo/

ls /usr/local/apache2.4/modules/libphp7.so

/usr/local/apache2.4/modules/libphp7.so

cp php.ini-production /usr/local/php7/etc/php.ini 解释跟php5一样

 

 

ls /usr/local/apache2.4/modules 下就有libphp7.so。查看Apache的模块

libphp5.so            mod_authn_dbm.so        mod_cache_disk.so     mod_file_cache.so           mod_macro.so           mod_proxy_scgi.so      mod_session.so           mod_userdir.so
libphp7.so            mod_authn_file.so       mod_cache.so          mod_filter.so               mod_mime.so            mod_proxy.so           mod_setenvif.so          mod_version.so
mod_access_compat.so  mod_authn_socache.so    mod_cache_socache.so  mod_headers.so              mod_negotiation.so     mod_proxy_uwsgi.so     mod_slotmem_shm.so       mod_vhost_alias.so
mod_actions.so        mod_authz_core.so       mod_cgid.so           mod_include.so              mod_proxy_ajp.so       mod_proxy_wstunnel.so  mod_socache_dbm.so       mod_watchdog.so
mod_alias.so          mod_authz_dbd.so        mod_dav_fs.so         mod_info.so                 mod_proxy_balancer.so  mod_ratelimit.so       mod_socache_memcache.so
mod_allowmethods.so   mod_authz_dbm.so        mod_dav.so            mod_lbmethod_bybusyness.so  mod_proxy_connect.so   mod_remoteip.so        mod_socache_redis.so
mod_auth_basic.so     mod_authz_groupfile.so  mod_dbd.so            mod_lbmethod_byrequests.so  mod_proxy_express.so   mod_reqtimeout.so      mod_socache_shmcb.so
mod_auth_digest.so    mod_authz_host.so       mod_dir.so            mod_lbmethod_bytraffic.so   mod_proxy_fcgi.so      mod_request.so         mod_speling.so
mod_auth_form.so      mod_authz_owner.so      mod_dumpio.so         mod_lbmethod_heartbeat.so   mod_proxy_fdpass.so    mod_rewrite.so         mod_status.so
mod_authn_anon.so     mod_authz_user.so       mod_env.so            mod_log_config.so           mod_proxy_ftp.so       mod_sed.so             mod_substitute.so
mod_authn_core.so     mod_autoindex.so        mod_expires.so        mod_log_debug.so            mod_proxy_hcheck.so    mod_session_cookie.so  mod_unique_id.so

/usr/local/php7/bin/php -m 查看php7加载的模块

dom
exif
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
mcrypt
mysqli
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

/usr/local/apache2.4/bin/apachectl -M 查看Apache加载了几个php。最下面就是php7和php5

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
Loaded Modules:
 core_module (static)
 so_module (static)
 http_module (static)
 mpm_event_module (static)
 authn_file_module (shared)
 authn_core_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_core_module (shared)
 access_compat_module (shared)
 auth_basic_module (shared)
 reqtimeout_module (shared)
 filter_module (shared)
 mime_module (shared)
 log_config_module (shared)
 env_module (shared)
 headers_module (shared)
 setenvif_module (shared)
 version_module (shared)
 unixd_module (shared)
 status_module (shared)
 autoindex_module (shared)
 dir_module (shared)
 alias_module (shared)
 php5_module (shared)
 php7_module (shared)

我们如何在PHP7和PHP5之间选择切换,修改配置文件:

vim /usr/local/apache2.4/conf/httpd.conf 在里面找到PHP5或PHP7(可/ 搜索php5.so),前面加#注释,注释掉这一个,就是使用另一个

#LoadModule php5_module modules/libphp5.so

LoadModule php7_module modules/libphp7.so

 

 

 

 

实例:

[root@localhost ~]# cd /usr/local/src

[root@localhost src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2

[root@localhost src]# ls

[root@localhost src]# tar -jxvf php-7.1.6.tar.bz2

[root@localhost src]# ls

apr-1.6.3 apr-util-1.6.1.tar.gz mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz php-5.6.32.tar.bz2

apr-1.6.3.tar.gz httpd-2.4.34 mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz php-7.1.6

apr-util-1.6.1 httpd-2.4.34.tar.gz php-5.6.32 php-7.1.6.tar.bz2

[root@localhost src]# cd php-7.1.6/

[root@localhost php-7.1.6]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

[root@localhost php-7.1.6]# echo $?

0

[root@localhost php-7.1.6]# make

[root@localhost php-7.1.6]# echo $?

0

[root@localhost php-7.1.6]# make install

[root@localhost php-7.1.6]# echo $?

0

[root@localhostphp-7.1.6]# cp php.ini-production /usr/local/php7/etc/php.ini

转载于:https://my.oschina.net/u/3866192/blog/3074147

library(deSolve) library(tidyverse) library(pracma) 1. 定义口服PBPK模型函数(包含多种制剂参数) pk_model_oral <- function(time, state, params) { with(as.list(c(state, params)), { # 计算胃肠道不同区段的pH值(随时间变化) if (time < gastric_emptying_time) { # 胃部环境 current_pH <- gastric_pH } else if (time < (gastric_emptying_time + small_intestine_transit_time)) { # 小肠环境 current_pH <- small_intestine_pH } else { # 结肠环境 current_pH <- colon_pH } # 计算pH依赖的溶解度 F_solubility <- calculate_pH_dependent_solubility( solubility_pH1 = solubility_pH1, solubility_pH2 = solubility_pH2, solubility_pH3 = solubility_pH3, solubility_pH4 = solubility_pH4, solubility_pH5 = solubility_pH5, solubility_pH6 = solubility_pH6, current_pH = current_pH, pKa = pKa, acid_base = acid_base ) # 计算pH依赖的logD current_logD <- calculate_pH_dependent_logD( logD_neutral = logD_neutral, pKa = pKa, acid_base = acid_base, current_pH = current_pH ) # 计算pH依赖的渗透性 F_permeability <- calculate_pH_dependent_permeability( Papp_ref = Papp_ref, Papp_compound = Papp_compound, current_pH = current_pH, pKa = pKa, acid_base = acid_base ) # 计算吸收速率 absorbed <- calculate_absorption( formulation_type = formulation_type, time = time, A_gi = A_gi, ka = ka, F_abs_intrinsic = F_abs_intrinsic, F_solubility = F_solubility, F_permeability = F_permeability, F_particle_size = F_particle_size, F_formulation = F_formulation, release_start = release_start, release_end = release_end, release_rate = release_rate, delay_time = delay_time, ka_factor = ka_factor ) dA_gi <- -absorbed dA_c <- absorbed - (CL / Vd) * A_c C_plasma <- (A_c / Vd) * 1000 # μg/mL -> ng/mL (血浆浓度) # 计算全血浓度 (考虑血/浆比) C_blood <- C_plasma / blood_plasma_ratio # 计算游离药物浓度 (考虑血浆蛋白结合) C_free <- C_plasma * fu_plasma return(list(c(dA_gi, dA_c), C_plasma = C_plasma, C_blood = C_blood, C_free = C_free, current_pH = current_pH, F_solubility = F_solubility, F_permeability = F_permeability, current_logD = current_logD)) }) } 2. pH依赖性溶解度计算函数 calculate_pH_dependent_solubility <- function(solubility_pH1, solubility_pH2, solubility_pH3, solubility_pH4, solubility_pH5, solubility_pH6, solubility_pH7, current_pH, pKa, acid_base) { 创建溶解度-pH数据框 solubility_data <- data.frame( pH = c(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0), solubility = c(solubility_pH1, solubility_pH2, solubility_pH3, solubility_pH4, solubility_pH5, solubility_pH6) ) 插值计算当前pH下的溶解度 F_solubility <- approx(solubility_data$pH, solubility_data$solubility, xout = current_pH, rule = 2)$y 对于弱酸/弱碱,应用Henderson-Hasselbalch方程校正 if (acid_base == “acid” && !is.na(pKa)) { # 弱酸: S = S0 * (1 + 10^(pKa - pH)) F_solubility <- solubility_pH7 * (1 + 10^(pKa - current_pH)) } else if (acid_base == “base” && !is.na(pKa)) { # 弱碱: S = S0 * (1 + 10^(pH - pKa)) F_solubility <- solubility_pH7 * (1 + 10^(current_pH - pKa)) } return(F_solubility) } 3. pH依赖性logD计算函数 calculate_pH_dependent_logD <- function(logD_neutral, pKa, acid_base, current_pH) { if (is.na(pKa)) return(logD_neutral) if (acid_base == “acid”) { # 弱酸: logD = logD_neutral - log(1 + 10^(pH - pKa)) logD <- logD_neutral - log10(1 + 10^(current_pH - pKa)) } else if (acid_base == “base”) { # 弱碱: logD = logD_neutral - log(1 + 10^(pKa - pH)) logD <- logD_neutral - log10(1 + 10^(pKa - current_pH)) } else { logD <- logD_neutral } return(logD) } 4. pH依赖性渗透性计算函数 calculate_pH_dependent_permeability <- function(Papp_ref, Papp_compound, current_pH, pKa, acid_base) { 参考渗透性 (美托洛尔作为阳性对照) ref_permeability <- 2e-4 # cm/s (高渗透性参考值) 计算基本渗透性因子 F_permeability <- Papp_compound / Papp_ref 考虑pH对分子形态的影响 if (!is.na(pKa) && !is.na(acid_base)) { if (acid_base == “acid”) { # 弱酸在低pH时主要以非离子形式存在,渗透性高 if (current_pH < pKa) { F_permeability <- F_permeability * 1.5 } else { F_permeability <- F_permeability * 0.7 } } else if (acid_base == “base”) { # 弱碱在高pH时主要以非离子形式存在,渗透性高 if (current_pH > pKa) { F_permeability <- F_permeability * 1.5 } else { F_permeability <- F_permeability * 0.7 } } } 限制在合理范围 F_permeability <- min(max(F_permeability, 0.1), 2.0) return(F_permeability) } 5. 吸收计算函数 calculate_absorption <- function(formulation_type, time, A_gi, ka, F_abs_intrinsic, F_solubility, F_permeability, F_particle_size, F_formulation, release_start, release_end, release_rate, delay_time, ka_factor) { 根据剂型计算吸收速率 if (formulation_type == “IR”) { # 速释制剂:一级吸收 absorbed <- ka * ka_factor * A_gi * F_abs_intrinsic * F_solubility * F_permeability } else if (formulation_type %in% c(“ER”, “SR”)) { # 缓释制剂:零级释放(在特定时间段内恒定释放) if (time >= release_start & time <= release_end) { absorbed <- release_rate * F_abs_intrinsic * F_solubility * F_permeability } else { absorbed <- 0 } } else if (formulation_type == “DR”) { # 延迟释放:延迟一段时间后开始一级吸收 if (time >= delay_time) { absorbed <- ka * ka_factor * A_gi * F_abs_intrinsic * F_solubility * F_permeability } else { absorbed <- 0 } } else if (formulation_type == “Nanoparticle”) { # 纳米制剂:增强的一级吸收 absorbed <- ka * ka_factor * 1.5 * A_gi * F_abs_intrinsic * F_solubility * F_permeability } 应用粒径和剂型影响因子 absorbed <- absorbed * F_particle_size * F_formulation return(absorbed) } 6. 动物口服PK数据准备(增加种属特异性参数) animal_data <- data.frame( species = c(“mouse”, “rat”, “dog”, “human”), weight_kg = c(0.02, 0.25, 9, 70), CL_animal = c(4.64, 7.61, 1.76, 0.8), # 清除率 (L/h/kg) Vd_animal = c(8.53, 22.8, 4.67, 6.0), # 分布容积 (L/kg) F_animal = c(0.16, 0.03, 0.29, NA), # 口服生物利用度 blood_plasma_ratio = c(0.75, 0.85, 0.95, 1.0), # 全血/血浆药物浓度比 fu_plasma = c(0.25, 0.35, 0.15, 0.05) # 血浆蛋白游离药物分数 ) 7. 外推人体参数(包含新增参数) extrapolate_human_pk <- function(animal_data, logD_neutral, pKa, acid_base, solubility_pH1, solubility_pH2, solubility_pH3, solubility_pH4, solubility_pH5, solubility_pH6, solubility_pH7, Papp_ref, Papp_compound, dose_mg, particle_size_um = 10, formulation_type = “IR”, human_weight = 70) { 基础PK参数计算 b_CL <- 0.75 # 清除率异速缩放指数 b_Vd <- 1.0 # 分布容积异速缩放指数 使用异速缩放方程外推人体参数 human_CL <- mean(animal_data$CL_animal[1:3]) * (human_weight/mean(animal_data$weight_kg[1:3]))^b_CL human_Vd <- mean(animal_data$Vd_animal[1:3]) * (human_weight/mean(animal_data$weight_kg[1:3]))^b_CL 计算吸收速率常数 (ka) - 使用logD替代logP human_ka <- 10^(0.54 * logD_neutral - 0.95) # 单位 h⁻¹ 固有生物利用度(不考虑制剂因素) F_abs_intrinsic <- mean(animal_data$F_animal[1:3], na.rm = TRUE) === 制剂参数影响计算 === 1. 粒径影响因子 (F_particle_size) if (particle_size_um <= 10) { F_particle_size <- 1 } else if (particle_size_um <= 50) { F_particle_size <- 0.8 } else { F_particle_size <- 0.6 } 2. 剂型影响因子 (F_formulation) formulation_factors <- c( “IR” = 1.0, # 速释制剂 “ER” = 0.8, # 缓释制剂 “SR” = 0.85, # 缓释制剂 “DR” = 0.9, # 延迟释放 “Nanoparticle” = 1.2 # 纳米制剂 ) F_formulation <- formulation_factors[[formulation_type]] 计算最终生物利用度 (F) - 溶解度、渗透性在模型中动态计算 human_F <- F_abs_intrinsic * F_particle_size * F_formulation 限制在0-1范围内 human_F <- max(0, min(1, human_F)) 计算半衰期 (h) human_t_half <- log(2) * human_Vd / human_CL 种属特异性参数 human_blood_plasma_ratio <- animal_data$blood_plasma_ratio[animal_data$species == “human”] human_fu_plasma <- animal_data$fu_plasma[animal_data$species == “human”] return(list( CL = human_CL, Vd = human_Vd, ka = human_ka, F = human_F, t_half = human_t_half, logD_neutral = logD_neutral, pKa = pKa, acid_base = acid_base, solubility_pH1 = solubility_pH1, solubility_pH2 = solubility_pH2, solubility_pH3 = solubility_pH3, solubility_pH4 = solubility_pH4, solubility_pH5 = solubility_pH5, solubility_pH6 = solubility_pH6, solubility_pH7 = solubility_pH7, Papp_ref = Papp_ref, Papp_compound = Papp_compound, F_particle_size = F_particle_size, F_formulation = F_formulation, F_abs_intrinsic = F_abs_intrinsic, blood_plasma_ratio = human_blood_plasma_ratio, fu_plasma = human_fu_plasma )) } 8. 设置化合物特性和制剂参数 logD_neutral <- 2.5 # 中性条件下的油水分配系数 pKa_value <- 4.5 # 酸碱解离平衡常数 acid_base <- “acid” # 酸性或碱性化合物(“acid"或"base”) pH依赖性溶解度 (mg/mL) solubility_pH1 <- 1.4 # pH 1.0 solubility_pH2 <- 2.5 # pH 2.0 solubility_pH3 <- 4.0 # pH 3.0 solubility_pH4 <- 5.0 # pH 4.0 solubility_pH5 <- 6.5 # pH 5.0 solubility_pH6 <- 7.4 # pH 6.0 渗透性参数 Papp_ref <- 20.5e-6 # 阳性对照物(美托洛尔)的Papp值 (cm/s) Papp_compound <- 15.2e-6 # 目标化合物的Papp值 (cm/s) 制剂参数 dose <- 200 # 口服剂量 (mg) human_weight <- 68 # 人体体重 (kg) particle_size_um <- 15 # 粒径 (μm) formulation_type <- “IR” # 剂型 (“IR”, “ER”, “SR”, “DR”, “Nanoparticle”) 胃肠道生理参数 gastric_pH <- 1.5 # 胃部pH small_intestine_pH <- 6.5 # 小肠pH colon_pH <- 7.0 # 结肠pH gastric_emptying_time <- 0.5 # 胃排空时间 (小时) small_intestine_transit_time <- 4 # 小肠转运时间 (小时) 9. 外推人体参数 (包含新增参数) human_pk <- extrapolate_human_pk( animal_data, logD_neutral = logD_neutral, pKa = pKa_value, acid_base = acid_base, solubility_pH1 = 0.08557, solubility_pH2 = 0.06794, solubility_pH3 = 0.07188, solubility_pH4 = 0.07629, solubility_pH5 = 0.08165, solubility_pH6 = 0.07515, Papp_ref = Papp_ref, Papp_compound = Papp_compound, dose_mg = dose, particle_size_um = particle_size_um, formulation_type = formulation_type, human_weight = human_weight ) 10. 设置剂型特定参数 set_formulation_params <- function(formulation_type) { params <- list() if (formulation_type == “IR”) { params$release_start <- 0 params$release_end <- 0 params$release_rate <- 0 params$delay_time <- 0 params$ka_factor <- 1.0 } else if (formulation_type == “ER”) { params$release_start <- 0.5 params$release_end <- 12 params$release_rate <- dose / (params$release_end - params$release_start) params$delay_time <- 0 params$ka_factor <- 1.0 } else if (formulation_type == “SR”) { params$release_start <- 0.5 params$release_end <- 24 params$release_rate <- dose / (params$release_end - params$release_start) params$delay_time <- 0 params$ka_factor <- 1.0 } else if (formulation_type == “DR”) { params$release_start <- 0 params$release_end <- 0 params$release_rate <- 0 params$delay_time <- 1.5 params$ka_factor <- 1.0 } else if (formulation_type == “Nanoparticle”) { params$release_start <- 0 params$release_end <- 0 params$release_rate <- 0 params$delay_time <- 0 params$ka_factor <- 1.5 } return(params) } form_params <- set_formulation_params(formulation_type) 11. 初始状态设置 state <- c( A_gi = dose, # 胃肠道初始药量 (mg) A_c = 0 # 中央室初始药量 (mg) ) 12. 完整参数集 params <- c( CL = human_pk$CL, Vd = human_pk$Vd, ka = human_pk$ka, F_abs_intrinsic = human_pk$F_abs_intrinsic, formulation_type = formulation_type, release_start = form_params$release_start, release_end = form_params$release_end, release_rate = form_params$release_rate, delay_time = form_params$delay_time, ka_factor = form_params$ka_factor, F_particle_size = human_pk$F_particle_size, F_formulation = human_pk$F_formulation, solubility_pH1 = human_pk$solubility_pH1, solubility_pH2 = human_pk$solubility_pH2, solubility_pH3 = human_pk$solubility_pH3, solubility_pH4 = human_pk$solubility_pH4, solubility_pH5 = human_pk$solubility_pH5, solubility_pH6 = human_pk$solubility_pH6, pKa = human_pk$pKa, acid_base = human_pk$acid_base, logD_neutral = human_pk$logD_neutral, Papp_ref = human_pk$Papp_ref, Papp_compound = human_pk$Papp_compound, gastric_pH = gastric_pH, small_intestine_pH = small_intestine_pH, colon_pH = colon_pH, gastric_emptying_time = gastric_emptying_time, small_intestine_transit_time = small_intestine_transit_time, blood_plasma_ratio = human_pk$blood_plasma_ratio, fu_plasma = human_pk$fu_plasma ) 13. 模型求解 times <- seq(0, 24, by = 0.1) solution <- ode( y = state, times = times, func = pk_model_oral, parms = params ) 14. 结果处理 results <- as.data.frame(solution) %>% mutate( Concentration_plasma = ifelse(is.na(C_plasma), 0, C_plasma), Concentration_blood = ifelse(is.na(C_blood), 0, C_blood), Concentration_free = ifelse(is.na(C_free), 0, C_free), pH = ifelse(is.na(current_pH), gastric_pH, current_pH), Solubility_factor = ifelse(is.na(F_solubility), 1, F_solubility), Permeability_factor = ifelse(is.na(F_permeability), 1, F_permeability), logD = ifelse(is.na(current_logD), logD_neutral, current_logD) ) 15. 可视化(多面板显示) p1 <- ggplot(results, aes(x = time, y = Concentration_plasma)) + geom_line(color = “blue”, linewidth = 1.2) + labs(title = “血浆药物浓度”, x = “时间 (小时)”, y = “浓度 (ng/mL)”) + theme_minimal() p2 <- ggplot(results, aes(x = time, y = pH)) + geom_line(color = “red”, linewidth = 1.2) + labs(title = “胃肠道pH变化”, x = “时间 (小时)”, y = “pH”) + theme_minimal() p3 <- ggplot(results, aes(x = time)) + geom_line(aes(y = Solubility_factor, color = “溶解度因子”), linewidth = 1.2) + geom_line(aes(y = Permeability_factor, color = “渗透性因子”), linewidth = 1.2) + geom_line(aes(y = logD/max(logD), color = “logD (归一化)”), linewidth = 1.2) + scale_color_manual(values = c(“溶解度因子” = “blue”, “渗透性因子” = “red”, “logD (归一化)” = “green”)) + labs(title = “吸收相关参数变化”, x = “时间 (小时)”, y = “因子值”) + theme_minimal() + theme(legend.position = “top”) p4 <- ggplot(results, aes(x = time)) + geom_line(aes(y = Concentration_plasma, color = “血浆总浓度”), linewidth = 1.2) + geom_line(aes(y = Concentration_free, color = “游离药物浓度”), linewidth = 1.2) + geom_line(aes(y = Concentration_blood, color = “全血浓度”), linewidth = 1.2) + scale_color_manual(values = c(“血浆总浓度” = “blue”, “游离药物浓度” = “red”, “全血浓度” = “purple”)) + labs(title = “不同浓度指标比较”, x = “时间 (小时)”, y = “浓度 (ng/mL)”) + theme_minimal() + theme(legend.position = “top”) 使用patchwork包组合图形 library(patchwork) combined_plot <- (p1 + p2) / (p3 + p4) + plot_annotation( title = “增强型口服PBPK模型模拟结果”, subtitle = sprintf(“化合物: %s (pKa=%.1f) | 剂型: %s | 剂量: %d mg”, acid_base, pKa_value, formulation_type, dose), theme = theme(plot.title = element_text(size = 16, face = “bold”)) ) print(combined_plot) 16. 输出关键PK参数 Cmax_plasma <- max(results$Concentration_plasma, na.rm = TRUE) Tmax <- results$time[which.max(results$Concentration_plasma)] AUC <- trapz(results$time, results$Concentration_plasma) cat(“=== 增强型PBPK模型参数汇总 =\n") cat(sprintf(“化合物类型: %s (pKa=%.1f)\n”, acid_base, pKa_value)) cat(sprintf(“中性logD: %.2f\n”, logD_neutral)) cat(sprintf(“吸收速率常数 (ka): %.2f h⁻¹\n”, human_pk$ka)) cat(sprintf(“清除率 (CL): %.2f L/h\n”, human_pk$CL)) cat(sprintf(“分布容积 (Vd): %.2f L\n”, human_pk$Vd)) cat(sprintf(“全血/血浆浓度比: %.2f\n”, human_pk$blood_plasma_ratio)) cat(sprintf(“血浆蛋白游离分数 (fu): %.3f\n”, human_pk$fu_plasma)) cat(sprintf(“Caco-2 Papp: %.2e cm/s (参考值: %.2e cm/s)\n”, Papp_compound, Papp_ref)) cat(sprintf(“半衰期 (t_{1/2}): %.2f h\n”, human_pk$t_half)) cat(sprintf(“峰浓度 (Cmax): %.2f ng/mL\n”, Cmax_plasma)) cat(sprintf(“达峰时间 (Tmax): %.1f h\n”, Tmax)) cat(sprintf(“药时曲线下面积 (AUC₀-₂₄): %.1f ng·h/mL\n”, AUC)) cat("\n= pH依赖性溶解度 ===\n”) cat(sprintf(“pH 1.0: %.2f mg/mL | pH 4.0: %.2f mg/mL\n”, solubility_pH1, solubility_pH4)) cat(sprintf(“pH 2.0: %.2f mg/mL | pH 5.0: %.2f mg/mL\n”, solubility_pH2, solubility_pH5)) cat(sprintf(“pH 3.0: %.2f mg/mL | pH 6.0: %.2f mg/mL\n”, solubility_pH3, solubility_pH6)) cat(sprintf(“pH 7.0: %.2f mg/mL\n”, solubility_pH7)) 错误于extrapolate_human_pk(animal_data, logD_neutral = logD_neutral, : 缺少参数"solubility_pH7",也缺失默认值,只有6个PH值的溶解度,删除"solubility_pH7"。
08-14
library(deSolve) library(tidyverse) library(pracma) # 1. 定义口服PBPK模型函数(包含多种制剂参数) pk_model_oral <- function(time, state, params) { with(as.list(c(state, params)), { # 计算胃肠道不同区段的pH值(随时间变化) if (time < gastric_emptying_time) { # 胃部环境 current_pH <- gastric_pH } else if (time < (gastric_emptying_time + small_intestine_transit_time)) { # 小肠环境 current_pH <- small_intestine_pH } else { # 结肠环境 current_pH <- colon_pH } # 计算pH依赖的溶解度 F_solubility <- calculate_pH_dependent_solubility( solubility_pH1 = solubility_pH1, solubility_pH2 = solubility_pH2, solubility_pH3 = solubility_pH3, solubility_pH4 = solubility_pH4, solubility_pH5 = solubility_pH5, solubility_pH6 = solubility_pH6, current_pH = current_pH, pKa = pKa, acid_base = acid_base ) # 计算pH依赖的logD current_logD <- calculate_pH_dependent_logD( logD_neutral = logD_neutral, pKa = pKa, acid_base = acid_base, current_pH = current_pH ) # 计算pH依赖的渗透性 F_permeability <- calculate_pH_dependent_permeability( Papp_ref = Papp_ref, Papp_compound = Papp_compound, current_pH = current_pH, pKa = pKa, acid_base = acid_base ) # 计算吸收速率 absorbed <- calculate_absorption( formulation_type = formulation_type, time = time, A_gi = A_gi, ka = ka, F_abs_intrinsic = F_abs_intrinsic, F_solubility = F_solubility, F_permeability = F_permeability, F_particle_size = F_particle_size, F_formulation = F_formulation, release_start = release_start, release_end = release_end, release_rate = release_rate, delay_time = delay_time, ka_factor = ka_factor ) dA_gi <- -absorbed dA_c <- absorbed - (CL / Vd) * A_c C_plasma <- (A_c / Vd) * 1000 # μg/mL -> ng/mL (血浆浓度) # 计算全血浓度 (考虑血/浆比) C_blood <- C_plasma / blood_plasma_ratio # 计算游离药物浓度 (考虑血浆蛋白结合) C_free <- C_plasma * fu_plasma return(list(c(dA_gi, dA_c), C_plasma = C_plasma, C_blood = C_blood, C_free = C_free, current_pH = current_pH, F_solubility = F_solubility, F_permeability = F_permeability, current_logD = current_logD)) }) } # 2. pH依赖性溶解度计算函数 calculate_pH_dependent_solubility <- function(solubility_pH1, solubility_pH2, solubility_pH3, solubility_pH4, solubility_pH5, solubility_pH6, current_pH, pKa, acid_base) { # 创建溶解度-pH数据框 solubility_data <- data.frame( pH = c(1.4,2.5,4.0,5.0,6.5,7.4), solubility = c(solubility_pH1, solubility_pH2, solubility_pH3, solubility_pH4, solubility_pH5, solubility_pH6) ) # 插值计算当前pH下的溶解度 F_solubility <- approx(solubility_data$pH, solubility_data$solubility, xout = current_pH, rule = 2)$y # 对于弱酸/弱碱,应用Henderson-Hasselbalch方程校正 if (acid_base == "acid" && !is.na(pKa)) { # 弱酸: S = S0 * (1 + 10^(pKa - pH)) F_solubility <- solubility_pH6 * (1 + 10^(pKa - current_pH)) } else if (acid_base == "base" && !is.na(pKa)) { # 弱碱: S = S0 * (1 + 10^(pH - pKa)) F_solubility <- solubility_pH6 * (1 + 10^(current_pH - pKa)) } return(F_solubility) } # 3. pH依赖性logD计算函数 calculate_pH_dependent_logD <- function(logD_neutral, pKa, acid_base, current_pH) { if (is.na(pKa)) return(logD_neutral) if (acid_base == "acid") { # 弱酸: logD = logD_neutral - log(1 + 10^(pH - pKa)) logD <- logD_neutral - log10(1 + 10^(current_pH - pKa)) } else if (acid_base == "base") { # 弱碱: logD = logD_neutral - log(1 + 10^(pKa - pH)) logD <- logD_neutral - log10(1 + 10^(pKa - current_pH)) } else { logD <- logD_neutral } return(logD) } # 4. pH依赖性渗透性计算函数 calculate_pH_dependent_permeability <- function(Papp_ref, Papp_compound, current_pH, pKa, acid_base) { # 参考渗透性 (美托洛尔作为阳性对照) ref_permeability <- 2e-4 # cm/s (高渗透性参考值) # 计算基本渗透性因子 F_permeability <- Papp_compound / Papp_ref # 考虑pH对分子形态的影响 if (!is.na(pKa) && !is.na(acid_base)) { if (acid_base == "acid") { # 弱酸在低pH时主要以非离子形式存在,渗透性高 if (current_pH < pKa) { F_permeability <- F_permeability * 1.5 } else { F_permeability <- F_permeability * 0.7 } } else if (acid_base == "base") { # 弱碱在高pH时主要以非离子形式存在,渗透性高 if (current_pH > pKa) { F_permeability <- F_permeability * 1.5 } else { F_permeability <- F_permeability * 0.7 } } } # 限制在合理范围 F_permeability <- min(max(F_permeability, 0.1), 2.0) return(F_permeability) } # 5. 吸收计算函数 calculate_absorption <- function(formulation_type, time, A_gi, ka, F_abs_intrinsic, F_solubility, F_permeability, F_particle_size, F_formulation, release_start, release_end, release_rate, delay_time, ka_factor) { # 根据剂型计算吸收速率 if (formulation_type == "IR") { # 速释制剂:一级吸收 absorbed <- ka * ka_factor * A_gi * F_abs_intrinsic * F_solubility * F_permeability } else if (formulation_type %in% c("ER", "SR")) { # 缓释制剂:零级释放(在特定时间段内恒定释放) if (time >= release_start & time <= release_end) { absorbed <- release_rate * F_abs_intrinsic * F_solubility * F_permeability } else { absorbed <- 0 } } else if (formulation_type == "DR") { # 延迟释放:延迟一段时间后开始一级吸收 if (time >= delay_time) { absorbed <- ka * ka_factor * A_gi * F_abs_intrinsic * F_solubility * F_permeability } else { absorbed <- 0 } } else if (formulation_type == "Nanoparticle") { # 纳米制剂:增强的一级吸收 absorbed <- ka * ka_factor * 1.5 * A_gi * F_abs_intrinsic * F_solubility * F_permeability } # 应用粒径和剂型影响因子 absorbed <- absorbed * F_particle_size * F_formulation return(absorbed) } # 6. 动物口服PK数据准备(增加种属特异性参数) animal_data <- data.frame( species = c("mouse", "rat", "dog", "human"), weight_kg = c(0.02, 0.25, 9, 70), CL_animal = c(4.64, 7.61, 1.76, 0.8), # 清除率 (L/h/kg) Vd_animal = c(8.53, 22.8, 4.67, 6.0), # 分布容积 (L/kg) F_animal = c(0.16, 0.03, 0.29, NA), # 口服生物利用度 blood_plasma_ratio = c(0.75, 0.85, 0.95, 1.0), # 全血/血浆药物浓度比 fu_plasma = c(0.25, 0.35, 0.15, 0.05) # 血浆蛋白游离药物分数 ) # 7. 外推人体参数(包含新增参数) extrapolate_human_pk <- function(animal_data, logD_neutral, pKa, acid_base, solubility_pH1, solubility_pH2, solubility_pH3, solubility_pH4, solubility_pH5, solubility_pH6, solubility_pH7, Papp_ref, Papp_compound, dose_mg, particle_size_um = 10, formulation_type = "IR", human_weight = 70) { # 基础PK参数计算 b_CL <- 0.75 # 清除率异速缩放指数 b_Vd <- 1.0 # 分布容积异速缩放指数 # 使用异速缩放方程外推人体参数 human_CL <- mean(animal_data$CL_animal[1:3]) * (human_weight/mean(animal_data$weight_kg[1:3]))^b_CL human_Vd <- mean(animal_data$Vd_animal[1:3]) * (human_weight/mean(animal_data$weight_kg[1:3]))^b_CL # 计算吸收速率常数 (ka) - 使用logD替代logP human_ka <- 10^(0.54 * logD_neutral - 0.95) # 单位 h⁻¹ # 固有生物利用度(不考虑制剂因素) F_abs_intrinsic <- mean(animal_data$F_animal[1:3], na.rm = TRUE) # === 制剂参数影响计算 === # 1. 粒径影响因子 (F_particle_size) if (particle_size_um <= 10) { F_particle_size <- 1 } else if (particle_size_um <= 50) { F_particle_size <- 0.8 } else { F_particle_size <- 0.6 } # 2. 剂型影响因子 (F_formulation) formulation_factors <- c( "IR" = 1.0, # 速释制剂 "ER" = 0.8, # 缓释制剂 "SR" = 0.85, # 缓释制剂 "DR" = 0.9, # 延迟释放 "Nanoparticle" = 1.2 # 纳米制剂 ) F_formulation <- formulation_factors[[formulation_type]] # 计算最终生物利用度 (F) - 溶解度、渗透性在模型中动态计算 human_F <- F_abs_intrinsic * F_particle_size * F_formulation # 限制在0-1范围内 human_F <- max(0, min(1, human_F)) # 计算半衰期 (h) human_t_half <- log(2) * human_Vd / human_CL # 种属特异性参数 human_blood_plasma_ratio <- animal_data$blood_plasma_ratio[animal_data$species == "human"] human_fu_plasma <- animal_data$fu_plasma[animal_data$species == "human"] return(list( CL = human_CL, Vd = human_Vd, ka = human_ka, F = human_F, t_half = human_t_half, logD_neutral = logD_neutral, pKa = pKa, acid_base = acid_base, solubility_pH1 = solubility_pH1, solubility_pH2 = solubility_pH2, solubility_pH3 = solubility_pH3, solubility_pH4 = solubility_pH4, solubility_pH5 = solubility_pH5, solubility_pH6 = solubility_pH6, Papp_ref = Papp_ref, Papp_compound = Papp_compound, F_particle_size = F_particle_size, F_formulation = F_formulation, F_abs_intrinsic = F_abs_intrinsic, blood_plasma_ratio = human_blood_plasma_ratio, fu_plasma = human_fu_plasma )) } # 8. 设置化合物特性和制剂参数 logD_neutral <- 2.5 # 中性条件下的油水分配系数 pKa_value <- 4.5 # 酸碱解离平衡常数 acid_base <- "acid" # 酸性或碱性化合物("acid"或"base") # pH依赖性溶解度 (mg/mL) solubility_pH1 <- 0.08557 # pH 1.4 solubility_pH2 <- 0.06794 # pH 2.5 solubility_pH3 <- 0.07188 # pH 4.0 solubility_pH4 <- 0.07629 # pH 5.0 solubility_pH5 <- 0.08165 # pH 6.5 solubility_pH6 <- 0.07515 # pH 7.4 # 渗透性参数 Papp_ref <- 20.5e-6 # 阳性对照物(美托洛尔)的Papp值 (cm/s) Papp_compound <- 15.2e-6 # 目标化合物的Papp值 (cm/s) # 制剂参数 dose <- 200 # 口服剂量 (mg) human_weight <- 68 # 人体体重 (kg) particle_size_um <- 15 # 粒径 (μm) formulation_type <- "IR" # 剂型 ("IR", "ER", "SR", "DR", "Nanoparticle") # 胃肠道生理参数 gastric_pH <- 1.5 # 胃部pH small_intestine_pH <- 6.5 # 小肠pH colon_pH <- 7.0 # 结肠pH gastric_emptying_time <- 0.5 # 胃排空时间 (小时) small_intestine_transit_time <- 4 # 小肠转运时间 (小时) # 9. 外推人体参数 (包含新增参数) human_pk <- extrapolate_human_pk( animal_data, logD_neutral = logD_neutral, pKa = pKa_value, acid_base = acid_base, solubility_pH1 = solubility_pH1, solubility_pH2 = solubility_pH2, solubility_pH3 = solubility_pH3, solubility_pH4 = solubility_pH4, solubility_pH5 = solubility_pH5, solubility_pH6 = solubility_pH6, Papp_ref = Papp_ref, Papp_compound = Papp_compound, dose_mg = dose, particle_size_um = particle_size_um, formulation_type = formulation_type, human_weight = human_weight ) # 10. 设置剂型特定参数 set_formulation_params <- function(formulation_type) { params <- list() if (formulation_type == "IR") { params$release_start <- 0 params$release_end <- 0 params$release_rate <- 0 params$delay_time <- 0 params$ka_factor <- 1.0 } else if (formulation_type == "ER") { params$release_start <- 0.5 params$release_end <- 12 params$release_rate <- dose / (params$release_end - params$release_start) params$delay_time <- 0 params$ka_factor <- 1.0 } else if (formulation_type == "SR") { params$release_start <- 0.5 params$release_end <- 24 params$release_rate <- dose / (params$release_end - params$release_start) params$delay_time <- 0 params$ka_factor <- 1.0 } else if (formulation_type == "DR") { params$release_start <- 0 params$release_end <- 0 params$release_rate <- 0 params$delay_time <- 1.5 params$ka_factor <- 1.0 } else if (formulation_type == "Nanoparticle") { params$release_start <- 0 params$release_end <- 0 params$release_rate <- 0 params$delay_time <- 0 params$ka_factor <- 1.5 } return(params) } form_params <- set_formulation_params(formulation_type) # 11. 初始状态设置 state <- c( A_gi = dose, # 胃肠道初始药量 (mg) A_c = 0 # 中央室初始药量 (mg) ) # 12. 完整参数集 params <- c( CL = human_pk$CL, Vd = human_pk$Vd, ka = human_pk$ka, F_abs_intrinsic = human_pk$F_abs_intrinsic, formulation_type = formulation_type, release_start = form_params$release_start, release_end = form_params$release_end, release_rate = form_params$release_rate, delay_time = form_params$delay_time, ka_factor = form_params$ka_factor, F_particle_size = human_pk$F_particle_size, F_formulation = human_pk$F_formulation, solubility_pH1 = human_pk$solubility_pH1, solubility_pH2 = human_pk$solubility_pH2, solubility_pH3 = human_pk$solubility_pH3, solubility_pH4 = human_pk$solubility_pH4, solubility_pH5 = human_pk$solubility_pH5, solubility_pH6 = human_pk$solubility_pH6, pKa = human_pk$pKa, acid_base = human_pk$acid_base, logD_neutral = human_pk$logD_neutral, Papp_ref = human_pk$Papp_ref, Papp_compound = human_pk$Papp_compound, gastric_pH = gastric_pH, small_intestine_pH = small_intestine_pH, colon_pH = colon_pH, gastric_emptying_time = gastric_emptying_time, small_intestine_transit_time = small_intestine_transit_time, blood_plasma_ratio = human_pk$blood_plasma_ratio, fu_plasma = human_pk$fu_plasma ) # 13. 模型求解 times <- seq(0, 24, by = 0.1) solution <- ode( y = state, times = times, func = pk_model_oral, parms = params ) # 14. 结果处理 results <- as.data.frame(solution) %>% mutate( Concentration_plasma = ifelse(is.na(C_plasma), 0, C_plasma), Concentration_blood = ifelse(is.na(C_blood), 0, C_blood), Concentration_free = ifelse(is.na(C_free), 0, C_free), pH = ifelse(is.na(current_pH), gastric_pH, current_pH), Solubility_factor = ifelse(is.na(F_solubility), 1, F_solubility), Permeability_factor = ifelse(is.na(F_permeability), 1, F_permeability), logD = ifelse(is.na(current_logD), logD_neutral, current_logD) ) # 15. 可视化(多面板显示) p1 <- ggplot(results, aes(x = time, y = Concentration_plasma)) + geom_line(color = "blue", linewidth = 1.2) + labs(title = "血浆药物浓度", x = "时间 (小时)", y = "浓度 (ng/mL)") + theme_minimal() p2 <- ggplot(results, aes(x = time, y = pH)) + geom_line(color = "red", linewidth = 1.2) + labs(title = "胃肠道pH变化", x = "时间 (小时)", y = "pH") + theme_minimal() p3 <- ggplot(results, aes(x = time)) + geom_line(aes(y = Solubility_factor, color = "溶解度因子"), linewidth = 1.2) + geom_line(aes(y = Permeability_factor, color = "渗透性因子"), linewidth = 1.2) + geom_line(aes(y = logD/max(logD), color = "logD (归一化)"), linewidth = 1.2) + scale_color_manual(values = c("溶解度因子" = "blue", "渗透性因子" = "red", "logD (归一化)" = "green")) + labs(title = "吸收相关参数变化", x = "时间 (小时)", y = "因子值") + theme_minimal() + theme(legend.position = "top") p4 <- ggplot(results, aes(x = time)) + geom_line(aes(y = Concentration_plasma, color = "血浆总浓度"), linewidth = 1.2) + geom_line(aes(y = Concentration_free, color = "游离药物浓度"), linewidth = 1.2) + geom_line(aes(y = Concentration_blood, color = "全血浓度"), linewidth = 1.2) + scale_color_manual(values = c("血浆总浓度" = "blue", "游离药物浓度" = "red", "全血浓度" = "purple")) + labs(title = "不同浓度指标比较", x = "时间 (小时)", y = "浓度 (ng/mL)") + theme_minimal() + theme(legend.position = "top") # 使用patchwork包组合图形 library(patchwork) combined_plot <- (p1 + p2) / (p3 + p4) + plot_annotation( title = "增强型口服PBPK模型模拟结果", subtitle = sprintf("化合物: %s (pKa=%.1f) | 剂型: %s | 剂量: %d mg", acid_base, pKa_value, formulation_type, dose), theme = theme(plot.title = element_text(size = 16, face = "bold")) ) print(combined_plot) # 16. 输出关键PK参数 Cmax_plasma <- max(results$Concentration_plasma, na.rm = TRUE) Tmax <- results$time[which.max(results$Concentration_plasma)] AUC <- trapz(results$time, results$Concentration_plasma) cat("=== 增强型PBPK模型参数汇总 ===\n") cat(sprintf("化合物类型: %s (pKa=%.1f)\n", acid_base, pKa_value)) cat(sprintf("中性logD: %.2f\n", logD_neutral)) cat(sprintf("吸收速率常数 (ka): %.2f h⁻¹\n", human_pk$ka)) cat(sprintf("清除率 (CL): %.2f L/h\n", human_pk$CL)) cat(sprintf("分布容积 (Vd): %.2f L\n", human_pk$Vd)) cat(sprintf("全血/血浆浓度比: %.2f\n", human_pk$blood_plasma_ratio)) cat(sprintf("血浆蛋白游离分数 (fu): %.3f\n", human_pk$fu_plasma)) cat(sprintf("Caco-2 Papp: %.2e cm/s (参考值: %.2e cm/s)\n", Papp_compound, Papp_ref)) cat(sprintf("半衰期 (t_{1/2}): %.2f h\n", human_pk$t_half)) cat(sprintf("峰浓度 (Cmax): %.2f ng/mL\n", Cmax_plasma)) cat(sprintf("达峰时间 (Tmax): %.1f h\n", Tmax)) cat(sprintf("药时曲线下面积 (AUC₀-₂₄): %.1f ng·h/mL\n", AUC)) cat("\n=== pH依赖性溶解度 ===\n") cat(sprintf("pH 1.0: %.2f mg/mL | pH 4.0: %.2f mg/mL\n", solubility_pH1, solubility_pH4)) cat(sprintf("pH 2.0: %.2f mg/mL | pH 5.0: %.2f mg/mL\n", solubility_pH2, solubility_pH5)) cat(sprintf("pH 3.0: %.2f mg/mL | pH 6.0: %.2f mg/mL\n", solubility_pH3, solubility_pH6)) cat(sprintf("pH 7.0: %.2f mg/mL\n", solubility_pH7)) 错误于pKa - current_pH: 二进列运算符中有非数值参数 Called from: calculate_pH_dependent_solubility(solubility_pH1 = solubility_pH1, solubility_pH2 = solubility_pH2, solubility_pH3 = solubility_pH3, solubility_pH4 = solubility_pH4, solubility_pH5 = solubility_pH5, solubility_pH6 = solubility_pH6, current_pH = current_pH, pKa = pKa, acid_base = acid_base) Browse[1]>
08-14
library(deSolve) library(tidyverse) library(pracma) # 1. 定义口服PBPK模型函数 pk_model_oral <- function(time, state, params) { with(as.list(c(state, params)), { if (time < gastric_emptying_time) { current_pH <- gastric_pH } else if (time < (gastric_emptying_time + small_intestine_transit_time)) { current_pH <- small_intestine_pH } else { current_pH <- colon_pH } # 修改后的溶解度计算函数 F_solubility <- calculate_pH_dependent_solubility( solubility_pH1 = solubility_pH1, solubility_pH2 = solubility_pH2, solubility_pH3 = solubility_pH3, solubility_pH4 = solubility_pH4, solubility_pH5 = solubility_pH5, solubility_pH6 = solubility_pH6, current_pH = current_pH ) # pH依赖的logD计算 current_logD <- calculate_pH_dependent_logD( logD_neutral = logD_neutral, pKa = pKa, acid_base = acid_base, current_pH = current_pH ) # pH依赖的渗透性 F_permeability <- calculate_pH_dependent_permeability( Papp_ref = Papp_ref, Papp_compound = Papp_compound, current_pH = current_pH, pKa = pKa, acid_base = acid_base ) # 吸收速率计算 absorbed <- calculate_absorption( formulation_type = formulation_type, time = time, A_gi = A_gi, ka = ka, F_abs_intrinsic = F_abs_intrinsic, F_solubility = F_solubility, F_permeability = F_permeability, F_particle_size = F_particle_size, F_formulation = F_formulation, release_start = release_start, release_end = release_end, release_rate = release_rate, delay_time = delay_time, ka_factor = ka_factor ) dA_gi <- -absorbed dA_c <- absorbed - (CL / Vd) * A_c C_plasma <- (A_c / Vd) * 1000 # μg/mL -> ng/mL # 全血浓度 (考虑血/浆比) C_blood <- C_plasma / blood_plasma_ratio # 游离药物浓度 C_free <- C_plasma * fu_plasma return(list(c(dA_gi, dA_c), C_plasma = C_plasma, C_blood = C_blood, C_free = C_free, current_pH = current_pH, F_solubility = F_solubility, F_permeability = F_permeability, current_logD = current_logD)) }) } # 2. 简化后的pH依赖性溶解度计算 calculate_pH_dependent_solubility <- function(solubility_pH1, solubility_pH2, solubility_pH3, solubility_pH4, solubility_pH5, solubility_pH6, current_pH) { solubility_data <- data.frame( pH = c(1.4, 2.5, 4.0, 5.0, 6.5, 7.4), solubility = c(solubility_pH1, solubility_pH2, solubility_pH3, solubility_pH4, solubility_pH5, solubility_pH6) ) # 插值计算当前pH下的溶解度 approx(solubility_data$pH, solubility_data$solubility, xout = current_pH, rule = 2)$y } # 3-5. 其他辅助函数保持不变(logD、渗透性、吸收计算) # 6. 动物数据 animal_data <- data.frame( species = c("mouse", "rat", "dog", "human"), weight_kg = c(0.02, 0.25, 9, 70), CL_animal = c(4.64, 7.61, 1.76, 0.8), Vd_animal = c(8.53, 22.8, 4.67, 6.0), F_animal = c(0.16, 0.03, 0.29, NA), blood_plasma_ratio = c(0.975, 1.576, 1.034, 0.954), fu_plasma = c(0.0873, 0.156, 0.0981, 0.0818) ) # 7. 外推人体参数(移除solubility_pH7) extrapolate_human_pk <- function(animal_data, logD_neutral, pKa, acid_base, solubility_pH1, solubility_pH2, solubility_pH3, solubility_pH4, solubility_pH5, solubility_pH6, Papp_ref, Papp_compound, dose_mg, particle_size_um = 10, formulation_type = "IR", human_weight = 70) { # ... [函数实现保持不变,但移除solubility_pH7引用] ... } # 8. 设置化合物参数 logD_neutral <- 0.954 # 中性logD值 pKa_value <- 8.8 # pKa值 acid_base <- "base" # 指定为碱性化合物 solubility_pH1 <- 0.08557 solubility_pH2 <- 0.06794 solubility_pH3 <- 0.07188 solubility_pH4 <- 0.07629 solubility_pH5 <- 0.08165 solubility_pH6 <- 0.07515 Papp_ref <- 20.5e-6 Papp_compound <- 31.2e-6 dose <- 200 human_weight <- 68 particle_size_um <- 15 formulation_type <- "IR" gastric_pH <- 1.5 small_intestine_pH <- 6.5 colon_pH <- 7.0 gastric_emptying_time <- 0.5 small_intestine_transit_time <- 4 # 9. 外推人体参数 human_pk <- extrapolate_human_pk( animal_data, logD_neutral = logD_neutral, pKa = pKa_value, acid_base = acid_base, solubility_pH1 = solubility_pH1, solubility_pH2 = solubility_pH2, solubility_pH3 = solubility_pH3, solubility_pH4 = solubility_pH4, solubility_pH5 = solubility_pH5, solubility_pH6 = solubility_pH6, Papp_ref = Papp_ref, Papp_compound = Papp_compound, dose_mg = dose, particle_size_um = particle_size_um, formulation_type = formulation_type, human_weight = human_weight ) # 10. 设置剂型特定参数 set_formulation_params <- function(formulation_type) { params <- list() if (formulation_type == "IR") { params$release_start <- 0 params$release_end <- 0 params$release_rate <- 0 params$delay_time <- 0 params$ka_factor <- 1.0 } else if (formulation_type == "ER") { params$release_start <- 0.5 params$release_end <- 12 params$release_rate <- dose / (params$release_end - params$release_start) params$delay_time <- 0 params$ka_factor <- 1.0 } else if (formulation_type == "SR") { params$release_start <- 0.5 params$release_end <- 24 params$release_rate <- dose / (params$release_end - params$release_start) params$delay_time <- 0 params$ka_factor <- 1.0 } else if (formulation_type == "DR") { params$release_start <- 0 params$release_end <- 0 params$release_rate <- 0 params$delay_time <- 1.5 params$ka_factor <- 1.0 } else if (formulation_type == "Nanoparticle") { params$release_start <- 0 params$release_end <- 0 params$release_rate <- 0 params$delay_time <- 0 params$ka_factor <- 1.5 } return(params) } form_params <- set_formulation_params(formulation_type) # 11. 初始状态设置 state <- c( A_gi = dose, # 胃肠道初始药量 (mg) A_c = 0 # 中央室初始药量 (mg) ) # 12. 完整参数集 params <- c( CL = human_pk$CL, Vd = human_pk$Vd, ka = human_pk$ka, F_abs_intrinsic = human_pk$F_abs_intrinsic, formulation_type = formulation_type, release_start = form_params$release_start, release_end = form_params$release_end, release_rate = form_params$release_rate, delay_time = form_params$delay_time, ka_factor = form_params$ka_factor, F_particle_size = human_pk$F_particle_size, F_formulation = human_pk$F_formulation, solubility_pH1 = human_pk$solubility_pH1, solubility_pH2 = human_pk$solubility_pH2, solubility_pH3 = human_pk$solubility_pH3, solubility_pH4 = human_pk$solubility_pH4, solubility_pH5 = human_pk$solubility_pH5, solubility_pH6 = human_pk$solubility_pH6, pKa = human_pk$pKa, acid_base = human_pk$acid_base, logD_neutral = human_pk$logD_neutral, Papp_ref = human_pk$Papp_ref, Papp_compound = human_pk$Papp_compound, gastric_pH = gastric_pH, small_intestine_pH = small_intestine_pH, colon_pH = colon_pH, gastric_emptying_time = gastric_emptying_time, small_intestine_transit_time = small_intestine_transit_time, blood_plasma_ratio = human_pk$blood_plasma_ratio, fu_plasma = human_pk$fu_plasma ) # 13. 模型求解 times <- seq(0, 24, by = 0.1) solution <- ode( y = state, times = times, func = pk_model_oral, parms = params ) # 14. 结果处理 results <- as.data.frame(solution) %>% mutate( Concentration_plasma = ifelse(is.na(C_plasma), 0, C_plasma), Concentration_blood = ifelse(is.na(C_blood), 0, C_blood), Concentration_free = ifelse(is.na(C_free), 0, C_free), pH = ifelse(is.na(current_pH), gastric_pH, current_pH), Solubility_factor = ifelse(is.na(F_solubility), 1, F_solubility), Permeability_factor = ifelse(is.na(F_permeability), 1, F_permeability), logD = ifelse(is.na(current_logD), logD_neutral, current_logD) ) # 15. 可视化(多面板显示) p1 <- ggplot(results, aes(x = time, y = Concentration_plasma)) + geom_line(color = "blue", linewidth = 1.2) + labs(title = "血浆药物浓度", x = "时间 (小时)", y = "浓度 (ng/mL)") + theme_minimal() p2 <- ggplot(results, aes(x = time, y = pH)) + geom_line(color = "red", linewidth = 1.2) + labs(title = "胃肠道pH变化", x = "时间 (小时)", y = "pH") + theme_minimal() p3 <- ggplot(results, aes(x = time)) + geom_line(aes(y = Solubility_factor, color = "溶解度因子"), linewidth = 1.2) + geom_line(aes(y = Permeability_factor, color = "渗透性因子"), linewidth = 1.2) + geom_line(aes(y = logD/max(logD), color = "logD (归一化)"), linewidth = 1.2) + scale_color_manual(values = c("溶解度因子" = "blue", "渗透性因子" = "red", "logD (归一化)" = "green")) + labs(title = "吸收相关参数变化", x = "时间 (小时)", y = "因子值") + theme_minimal() + theme(legend.position = "top") p4 <- ggplot(results, aes(x = time)) + geom_line(aes(y = Concentration_plasma, color = "血浆总浓度"), linewidth = 1.2) + geom_line(aes(y = Concentration_free, color = "游离药物浓度"), linewidth = 1.2) + geom_line(aes(y = Concentration_blood, color = "全血浓度"), linewidth = 1.2) + scale_color_manual(values = c("血浆总浓度" = "blue", "游离药物浓度" = "red", "全血浓度" = "purple")) + labs(title = "不同浓度指标比较", x = "时间 (小时)", y = "浓度 (ng/mL)") + theme_minimal() + theme(legend.position = "top") # 使用patchwork包组合图形 library(patchwork) combined_plot <- (p1 + p2) / (p3 + p4) + plot_annotation( title = "增强型口服PBPK模型模拟结果", subtitle = sprintf("化合物: %s (pKa=%.1f) | 剂型: %s | 剂量: %d mg", acid_base, pKa_value, formulation_type, dose), theme = theme(plot.title = element_text(size = 16, face = "bold")) ) print(combined_plot) # 16. 修正输出部分 cat("=== 增强型PBPK模型参数汇总 ===\n") cat(sprintf("化合物类型: %s (pKa=%.1f)\n", acid_base, pKa_value)) cat(sprintf("中性logD: %.2f\n", logD_neutral)) cat(sprintf("吸收速率常数 (ka): %.2f h⁻¹\n", human_pk$ka)) cat(sprintf("清除率 (CL): %.2f L/h\n", human_pk$CL)) cat(sprintf("分布容积 (Vd): %.2f L\n", human_pk$Vd)) cat(sprintf("Cmax: %.2f ng/mL\n", Cmax_plasma)) cat(sprintf("Tmax: %.1f h\n", Tmax)) cat(sprintf("AUC₀-₂₄: %.1f ng·h/mL\n", AUC)) # 修正后的溶解度输出 cat("\n=== pH依赖性溶解度 ===\n") cat(sprintf("pH 1.4: %.5f mg/mL | pH 5.0: %.5f mg/mL\n", solubility_pH1, solubility_pH4)) cat(sprintf("pH 2.5: %.5f mg/mL | pH 6.5: %.5f mg/mL\n", solubility_pH2, solubility_pH5)) cat(sprintf("pH 4.0: %.5f mg/mL | pH 7.4: %.5f mg/mL\n", solubility_pH3, solubility_pH6)) > # 13. 模型求解 > times <- seq(0, 24, by = 0.1) > solution <- ode( + y = state, + times = times, + func = pk_model_oral, + parms = params + ) 错误于eval(substitute(expr), data, enclos = parent.frame()): 找不到对象&#39;pKa&#39; Called from: calculate_pH_dependent_logD(logD_neutral = logD_neutral, pKa = pKa, acid_base = acid_base, current_pH = current_pH) Browse[1]>
08-14
data31=[ph3_1(67:76,65),ph3_1(67:76,:)] data32=[ph3_2(117:133,65),ph3_2(117:133,:)] data33=[ph3_3(124:133,65),ph3_3(124:133,:)] data34=[ph3_4(76:86,65),ph3_4(76:86,:)] data35=[ph3_5(114:132,65),ph3_5(114:132,:)] data31h=[ph3_1h(130:140,65),ph3_1h(130:140,:)] data32h=[ph3_2h(141:152,65),ph3_2h(141:152,:)] data41=[ph4_1(84:99,65),ph4_1(84:99,:)] data41h=[ph4_1h(110:125,65),ph4_1h(110:125,:)] data42h=[ph4_2h(112:119,65),ph4_2h(112:119,:)] data51=[ph5_1(76:91,65),ph5_1(76:91,:)] data52=[ph5_2(88:100,65),ph5_2(88:100,:)] data51h=[ph5_1h(114:128,65),ph5_1h(114:128,:)] data52h=[ph5_2h(161:172,65),ph5_2h(161:172,:)] data61=[ph6_1(135:143,65),ph6_1(135:143,:)] data62=[ph6_2(148:167,65),ph6_2(148:167,:)] data61h=[ph6_1h(124:138,65),ph6_1h(124:138,:)] data62h=[ph6_2h(156:166,65),ph6_2h(156:166,:)] data71=[ph7_1(96:110,65),ph7_1(96:110,:)] data72=[ph7_2(167:182,65),ph7_2(167:182,:)] data71h=[ph7_1h(154:170,65),ph7_1h(154:170,:)] data72h=[ph7_2h(179:193,65),ph7_2h(179:193,:)] data81=[ph8_1(124:134,65),ph8_1(124:134,:)] data82=[ph8_2(100:119,65),ph8_2(100:119,:)] data81h=[ph8_1h(122:133,65),ph8_1h(122:133,:)] data91=[ph9_1(278:290,65),ph9_1(278:290,:)] data91h=[ph9_1h(100:122,65),ph9_1h(100:122,:)] data92h=[ph9_2h(146:157,65),ph9_2h(146:157,:)] data101=[ph10_1(149:159,65),ph10_1(149:159,:)] data101h=[ph10_1h(181:193,65),ph10_1h(181:193,:)] data102h=[ph10_2h(230:241,65),ph10_2h(230:241,:)] p31=mean(data31) p32=mean(data32) p33=mean(data33) p34=mean(data34) p35=mean(data35) pj3=cat(1,p31,p32,p33,p34,p35) dp3=mean(pj) p31h=mean(data31h) p32h=mean(data32h) pj3h=cat(1,p31h,p32h) dp3h=mean(pj3h) pj3cj=mean(1.33,1.4,1.32,1.36,1.39) pj3cjh=mean(158,140) pjph=dp3h-dp3 pjcjh3=pj3cjh-pj3cj plot(pjph)%平均训练与不训练姿势差别 将该代码转化为可循环计算的通用MATLAB代码
最新发布
09-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值