文章SameStr(二):图2代码

在这里插入图片描述

title: “Publication Figure 2”

百度云盘链接: https://pan.baidu.com/s/15g7caZp354zIWktpnWzWhQ

提取码: 4sh7

Libraries

Standard Import

library(tidyverse)
library(cowplot)
library(scales)
library(ggpubr)

Special

library(lme4)
library(sjPlot)
library(sjstats)
library(sjlabelled)

Paths

bin_dir = '../bin/'
data_dir = '../data/'
results_dir = '../results/'

Custom Scripts / Theme

source(paste0(bin_dir, 'theme_settings.R'))
source (paste0(bin_dir, 'utilities.R'))
source(paste0(bin_dir, 'species_competition_functions.R'))
source(paste0(bin_dir, 'analysis_metadata.R'))
date <- format(Sys.time(), "%d%m%y")

Import Tables

Metadata

samples.metadata <- read_tsv(paste0(data_dir, 'samples.metadata.tsv'))
microbe.taxonomy <- read_tsv(paste0(data_dir, 'microbe.taxonomy.tsv'))
microbe.metadata <- microbe.taxonomy %>% right_join(., read_tsv(paste0(data_dir, 'microbe.metadata.tsv'))) 

Taxonomy

MetaPhlAn2 tables
combine with taxonomy

mp_species.long <- microbe.taxonomy %>% right_join(., read_tsv(paste0(data_dir, 'samples.mp_profiles.species.tsv')), by = 'species') %>% left_join(., samples.metadata, by = 'Name')

rCDI subset
annotate with metadata

mp_species.rcdi.long <- mp_species.long %>%filter(Study %in% c(rcdi.studies)) 

Case Summary

SameStr Case-Summary table

sstr_cases <- read_tsv(paste0(data_dir, 'samples.case_summary.tsv')) %>% left_join(., microbe.taxonomy, by = 'species')

Set Figure

fig = paste0('Fig_2.')

Species-level Source

Mean across Cases

Species-level plot of mean post-FMT rel. abund. by source, using the last available time point of successful FMT cases.

Format

sstr_cases.source_mean <-sstr_cases %>% dplyr::filter(fmt_success, last_sample) %>% dplyr::mutate(unclassified_sp = ifelse(grepl(species, pattern = '_unclassified'), 'unclassified', 'classified')) %>% dplyr::group_by(Study_Type, Case_Name, Days_Since_FMT.post, unclassified_sp) %>% summarize_existed(.) %>% dplyr::group_by(Study_Type, unclassified_sp) %>% pivot_wider(names_from = 'unclassified_sp', values_from = matches('^[nrf].'),names_sep = '.', id_cols = c('Study_Type', 'Case_Name', 'Days_Since_FMT.post')) %>% dplyr::select(Study_Type, Case_Name, Days_Since_FMT.post, starts_with('r.')) %>%dplyr::group_by(Study_Type, Case_Name, Days_Since_FMT.post) %>% pivot_longer(names_to = 'source', values_to = 'rel_abund', cols = starts_with('r.')) %>% dplyr::ungroup() %>% separate(source, into = c(NA,'Sample','source','classified_sp')) %>% dplyr::filter(!source %in% c('either', 'any')) %>%dplyr::mutate(tag.source = case_when(classified_sp == 'unclassified' ~ 'Unclassified', (Sample == 'donor' & source == 'post') | (Sample == 'post' & source == 'donor') ~ 'Donor-Specific', (Sample == 'recipient' & source == 'post') | (Sample == 'post' & source == 'recipient') ~ 'Recipient-Specific',source == 'before' ~ 'Shared R/D', source == 'both' ~ 'Same Sp.',Sample == 'post' & source == 'unique' ~ 'New',T ~ str_to_title(source))) %>%  dplyr::mutate(tag.source = as.factor(tag.source)) %>% dplyr::mutate(Sample = str_to_title(str_extract(Sample, pattern = '.'))) %>% dplyr::select(Study_Type, Sample, tag.source, rel_abund) %>% dplyr::group_by(Study_Type, Sample, tag.source) %>%dplyr::summarize_all(.funs = funs(rel_abund.mean = round(mean(., na.rm = T), 2),rel_abund.sd = round(sd(., na.rm = T), 2))) %>% dplyr::ungroup()

Statistics

Data

sstr_cases.samples <-sstr_cases %>% dplyr::filter(fmt_success, last_sample) %>%dplyr::select(Study_Type, Study, Case_Name, Sample.recipient, Sample.post, Sample.donor, fmt_success) %>% dplyr::distinct() %>% dplyr::filter(Study_Type == 'rCDI')
paste0('Recipient: ', length(unique(sstr_cases.samples$Sample.recipient)))
paste0('Post-FMT: ', length(unique(sstr_cases.samples$Sample.post)))
paste0('Donor: ', length(unique(sstr_cases.samples$Sample.donor)))

Last Post-FMT time point of successfully treated patients had species-level sources:

  • 54.41% Same Sp.
  • 24.95% Donor-Specific
  • 11.33% Unclassified
  • 7.65% Recipient-Specific
  • 1.52% New/Unique
    Unseen/Unclear: 11.33 + 1.51 = 12.84%
sstr_cases.source_mean %>% pivot_wider(names_from = 'Sample', values_from = c('rel_abund.mean', 'rel_abund.sd'), names_sep = '.') %>% dplyr::mutate_at(.vars = vars(starts_with('rel_abund')), .funs = funs(replace_na(., 0))) %>% dplyr::select(Study_Type, tag.source, ends_with('R'), ends_with('P'), ends_with('D')) %>% dplyr::arrange(desc(Study_Type), desc(rel_abund.mean.P))

Pie Chart

Pie chart showing rel. abund. of sets of co-occurring species in recipients, donors, and post-FMT patients. Only a small fraction of post-FMT species has not been observed in the recipient or donor before.

coord_polar_fix <- coord_polar(theta = "y", start = 7.15)
coord_polar_fix$is_free <- function() TRUEplot <-sstr_cases.source_mean %>% dplyr::mutate(tag.source = fct_relevel(tag.source, 'Donor-Specific', 'New', 'Recipient-Specific','Unique', 'Shared R/D', 'Same Sp.', 'Unclassified')) %>% ggplot(aes(x = fct_relevel(Sample, 'R', 'P', 'D'), y = rel_abund.mean, fill = tag.source)) +   geom_bar(stat = 'identity', position = 'fill', color = 'black') + # facet_grid(rows = vars(fct_relevel(Study_Type, 'rCDI')), cols = vars(fct_relevel(Sample, 'R', 'P', 'D')),scales = 'free', switch = 'y') + scale_fill_manual(values = c(colors.discrete[c(1, 2, 3)], 'white', 'black', colors.discrete[c(5, 10)])) + theme_cowplot() + coord_polar_fix + theme(aspect.ratio = 1, axis.text = element_blank(),axis.title = element_blank(),axis.line = element_blank(),axis.ticks = element_blank(),strip.background = element_blank(),panel.spacing = unit(-0.5, "lines"),strip.text = element_text(size = 14),legend.title = element_blank())plot

在这里插入图片描述

Exporting plot

output_name = 'PostSource.Mean_SuccessfulCases.Species'ggsave(plot + theme(legend.position = 'none'), device = 'pdf', dpi = 300, width = 3, height = 2,filename = paste0(results_dir, fig, output_name, '.Plot.pdf'))

Case-Wise

Species-level plot of per-Case post-FMT rel. abund. by source

Format

sstr_cases.source_case <-sstr_cases %>%dplyr::mutate(n = 1) %>% dplyr::select(Study_Type, Case_Name, Days_Since_FMT.post, fmt_success.label, kingdom, phylum, class, order, family, genus, species, n, rel_abund.recipient, rel_abund.post, rel_abund.donor) %>% dplyr::mutate(source = case_when(grepl(species, pattern = '_unclassified') ~ 'Unclassified Sp.', (rel_abund.recipient > 0) & (rel_abund.donor > 0) & (rel_abund.post == 0) ~ 'Shared Before',(rel_abund.recipient > 0) & (rel_abund.donor > 0) & (rel_abund.post > 0) ~ 'Same Sp.',(rel_abund.recipient > 0) & (rel_abund.donor == 0) & (rel_abund.post > 0) ~ 'Recipient / Initial Sample',(rel_abund.recipient == 0) & (rel_abund.donor > 0) & (rel_abund.post > 0) ~ 'Donor',(rel_abund.recipient > 0) & (rel_abund.donor == 0) & (rel_abund.post == 0) ~ 'Unique Recipient',(rel_abund.recipient == 0) & (rel_abund.donor > 0) & (rel_abund.post == 0) ~ 'Unique Donor',(rel_abund.recipient == 0) & (rel_abund.donor == 0) & (rel_abund.post > 0) ~ 'Unique to Time Point',T ~ 'Other')) %>% dplyr::filter(!source %in% c('Unique Donor', 'Unique Recipient', 'Shared Before')) %>% dplyr::filter(rel_abund.post > 0) %>% dplyr::group_by(Study_Type, Case_Name, Days_Since_FMT.post, fmt_success.label) %>% dplyr::mutate(f = n / sum(n, na.rm = T)) %>% pivot_longer(names_to = 'metric', values_to = 'value', cols = c('rel_abund.post', 'n', 'f')) %>% dplyr::group_by(Study_Type, Case_Name, Days_Since_FMT.post, fmt_success.label, source, metric) %>% dplyr::summarize(value = sum(value), .groups = 'drop') %>% dplyr::mutate(value = ifelse(metric == 'rel_abund.post',  value / 100, value),metric = case_when(metric == 'rel_abund.post' ~ 'Rel. Abund.', metric == 'f' ~ 'Spp. Fraction', metric == 'n' ~ 'Count of Spp.', T ~ 'Other'))

Bar Charts, per Case

rCDI - Bar charts showing post-FMT rel. abund. of sets of co-occurring species in recipients, donors, and post-FMT patients.

source_order <- c('Donor', 'Recipient / Initial Sample', 'Unique to Time Point', 'Same Sp.')plot.rcdi <-sstr_cases.source_case %>% dplyr::filter(metric == "Rel. Abund.") %>% dplyr::filter(Study_Type == 'rCDI') %>% dplyr::mutate(ordering = -as.numeric(as.factor(Case_Name)) + (Days_Since_FMT.post/1000)) %>% ggplot(aes(fct_reorder(paste0('D', Days_Since_FMT.post, ' | ', str_remove(Case_Name, pattern = 'Case_')), ordering),y = value, fill = fct_relevel(source, source_order))) + geom_bar(stat = 'identity', position = position_fill(), width = 1, col = 'black') +theme_cowplot() + scale_y_continuous(labels = percent_format(),breaks = c(1, .75, .5, .25, 0),expand = c(0,0)) +scale_fill_manual(values = c(colors.discrete[c(1, 3, 2, 5, 10)]), guide = guide_legend(reverse = TRUE)) + labs(y = 'Rel. Abund.') + theme(axis.title.x = element_blank(),axis.line.y = element_blank(),axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5, size = 10),axis.ticks.x = element_blank(),legend.title=element_blank(),legend.position = 'top')
plot.rcdi

在这里插入图片描述

Control - Bar charts showing >=second time point rel. abund. of sets of co-occurring species in first and second time points of controls.

plot.control <- sstr_cases.source_case %>% dplyr::filter(metric == "Rel. Abund.") %>% dplyr::filter(Study_Type == 'Control') %>% dplyr::filter(Days_Since_FMT.post <= 373) %>% # ~ same time range as last rcdidplyr::mutate(ordering = as.numeric(as.factor(Case_Name)) + (Days_Since_FMT.post/1000)) %>% ggplot(aes(fct_reorder(paste0('D', Days_Since_FMT.post, ' | ', str_remove(Case_Name, pattern = 'Case_')), ordering),y = value, fill = fct_relevel(source, source_order))) + geom_bar(stat = 'identity', position = position_fill(), width = 1, col = 'black') +theme_cowplot() + scale_y_continuous(labels = percent_format(),breaks = c(1, .75, .5, .25, 0),expand = c(0,0)) +scale_fill_manual(values = c(colors.discrete[c(3, 2, 10)]), guide = guide_legend(reverse = TRUE)) + labs(y = 'Rel. Abund.') + theme(axis.title.x = element_blank(),axis.line.y = element_blank(),axis.ticks.x = element_blank(),axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5, size = 7.5),legend.title=element_blank(),legend.position = 'top')
plot.control

Exporting plots

output_name = 'PostSource.Cases.rCDI.Species'
ggsave(plot.rcdi + theme(legend.position = 'none'), device = 'pdf', dpi = 300, width = 9, height = 3.5,filename = paste0(results_dir, fig, output_name, '.Plot.pdf'))
output_name = 'PostSource.Cases.Control.Species'
ggsave(plot.control + theme(legend.position = 'none'), device = 'pdf', dpi = 300, width = 25, height = 3.5,filename = paste0(results_dir, fig, output_name, '.Plot.pdf'))

Post-FMT Presence/Absence (Species)

Using GLMM to model post-FMT species presence/absence post-FMT.
We only have sparse data and single cases for later time points, limiting to <= 84 days

sstr_cases %>%dplyr::filter(Days_Since_FMT.post <= 84) %>%dplyr::filter(Study_Type %in% c('rCDI') ) %>% dplyr::filter(kingdom == 'Bacteria') %>% dplyr::filter(fmt_success) %>% dplyr::distinct(Days_Since_FMT.post) %>% summary(.)

Format

scale_gelman <- function(x) {return((x - mean(x)) / (2 * sd(x)))
}sstr_cases.scaled <- sstr_cases %>%dplyr::filter(Study_Type %in% c('rCDI') ) %>% dplyr::filter(kingdom == 'Bacteria') %>% dplyr::filter(fmt_success, Days_Since_FMT.post <= 84) %>%dplyr::mutate(source = ifelse(grepl(species, pattern = 'unclassified'),  'Unclassified', source)) %>%dplyr::mutate(source = case_when(analysis_level == 'species' & source == 'self' ~ 'Self Sp.',analysis_level == 'species' & source == 'donor' ~ 'Donor Sp.',analysis_level == 'species' & source == 'unique' ~ 'Unique Sp.',T ~ source)) %>% dplyr::left_join(., microbe.metadata) %>%dplyr::mutate(habit.oral = ifelse(is.na(habit.oral), F, habit.oral)) %>% dplyr::mutate(Donor = replace_na(rel_abund.donor > 0, F), PostTreatment = replace_na(rel_abund.post > 0, F), Pre = replace_na(rel_abund.recipient > 0, F),Both = Donor & Pre, Any = Donor | Pre) %>% mutate(Engrafted = `Donor/Post-FMT.mvs` > min_similarity & `Donor/Post-FMT.overlap` > min_overlap) %>%mutate(Engrafted = replace_na(Engrafted, F),Engrafted = ifelse(analysis_level == 'species' |grepl(species, pattern = 'unclassified') |!species %in% microbe.metadata$species, NA, Engrafted)) %>% # filter only species that existed in any of recipient or donordplyr::filter(Any) %>%dplyr::rename(OxyTol = 'oxygen.tolerant', OxyClass = 'oxygen.class',DaysSinceFMT = 'Days_Since_FMT.post', Case = 'Case_Name',AbundanceDonor = 'rel_abund.donor',AbundanceRecipient = 'rel_abund.recipient',AbundancePost = 'rel_abund.post') %>% dplyr::mutate(Habitat = ifelse(habit.oral, 'Oral', 'Not-Oral'),OxyTol = ifelse(OxyTol, 'Tolerant', 'Not-Tolerant')) %>% dplyr::mutate(Detected = case_when(Pre & !Donor ~ 'Recipient', !Pre & Donor ~ 'Donor',Pre & Donor ~ 'Both')) %>% dplyr::mutate(Specificity = ifelse(Detected == 'Both', F, T)) %>% dplyr::mutate_at(.vars = vars(Case, Specificity, Detected, Engrafted,phylum, class, order, family,OxyTol, OxyClass, Habitat, PostTreatment,),.funs = funs(as.factor(.))) %>% dplyr::mutate(Detected = fct_relevel(Detected, 'Recipient'), OxyClass = fct_relevel(OxyClass, 'aerobe'),Habitat = fct_relevel(Habitat, 'Not-Oral'),OxyTol = fct_relevel(OxyTol, 'Not-Tolerant'),Phylum = fct_relevel(phylum, 'Firmicutes')) %>% dplyr::select(phylum:species, Engrafted, PostTreatment, AbundancePost, Detected, AbundanceDonor, AbundanceRecipient, Habitat, OxyTol, DaysSinceFMT, Case, OxyClass) %>% dplyr::mutate(AbundanceDonor = pseudo_log_trans(1e-4, 10)$transform(AbundanceDonor),AbundanceRecipient = pseudo_log_trans(1e-4, 10)$transform(AbundanceRecipient),AbundanceRatio = AbundanceDonor-AbundanceRecipient,DaysSinceFMT = log10(DaysSinceFMT))  %>% dplyr::mutate_at(.vars = vars(starts_with('Abundance'), DaysSinceFMT),.funs = funs(scale_gelman(.)))

GLMM Model

Using cases as random effect to account for repeated measurements

fit.rcdi <- glmer(PostTreatment ~ Detected +AbundanceDonor + AbundanceRecipient + AbundanceRecipient:AbundanceDonor + Detected:DaysSinceFMT + Detected:Habitat + Detected:OxyTol +(1 | Case), family=binomial(link='logit'), data=sstr_cases.scaled)
summary(fit.rcdi)

在这里插入图片描述

Forest Plot

a = 'Presence\nBefore FMT'
b = 'Relative\nAbundance'
c = 'Physiology'
d = 'Days\nSince FMT' 
e = 'Oral Habitat' 
f = 'Oxygen Tolerant' plot <-sjPlot::plot_model(fit.rcdi, se = T, vline.color = "black", wrap.labels = 1e4, # transform = NULL,sort.est = F, show.p = T, show.values = T, value.offset = 0.35, colors = 'black', axis.title = 'Log of Odds Ratio (95% CI)',group.terms = c(a,a, b,b,b, d,d,d, e,e,e, f,f,f),title = 'Species Presence Post-FMT') + theme_cowplot() + theme(strip.background = element_blank(), strip.text.y.left = element_text(angle = 0, hjust = 0), plot.title = element_blank(),axis.text.y = element_text(size = 11)) + facet_grid(rows = vars(fct_relevel(group, a, b, d, e, f)),scales = 'free_y', space = 'free_y', switch = 'y') +scale_x_discrete(labels = c("DetectedBoth" = "Found in Both*","DetectedDonor" = "Donor-Specific*",'AbundanceDonor' = 'Donor','AbundanceRecipient' = 'Recipient','AbundanceDonor:AbundanceRecipient' = 'Ratio D/R',"DetectedRecipient:DaysSinceFMT" = "Recipient-Specific","DetectedBoth:DaysSinceFMT" = "Found in Both","DetectedDonor:DaysSinceFMT" = "Donor-Specific","DetectedRecipient:HabitatOral" = "Recipient-Specific","DetectedBoth:HabitatOral" = "Found in Both","DetectedDonor:HabitatOral" = "Donor-Specific","DetectedRecipient:OxyTolTolerant" = "Recipient-Specific","DetectedBoth:OxyTolTolerant" = "Found in Both","DetectedDonor:OxyTolTolerant" = "Donor-Specific")) +scale_y_continuous(expand = c(0.1,0)) 
plot

在这里插入图片描述

Exporting plots, tables

output_name = 'PostPresence.Species.GLMM'# write model stats to html
sjPlot::tab_model(fit.rcdi, prefix.labels = "varname", transform = NULL,file = paste0(results_dir, fig, output_name, '.Model.html'))ggsave(plot + theme(legend.position = 'none'), device = 'pdf', dpi = 300, width = 6, height = 5,filename = paste0(results_dir, fig, output_name, '.Plot.pdf'))

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/43318.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

根据https链接点击按钮下载文件

filePreview(row) {fetch(row.attachmentContent.url).then(res >res.blob().then(blob > {var a document.createElement(a);var url window.URL.createObjectURL(blob);var name row.attachmentContent.name;a.href url;a.download name; // 下载名称a.click();wi…

数据仓库之命名规范

数据仓库命名规范旨在确保数据仓库中的各种对象&#xff08;如数据库、表、列、索引、视图等&#xff09;具有一致、清晰且有意义的名称。这些规范有助于提高数据的可读性、可维护性和可理解性。以下是一些常见的数据仓库命名规范&#xff0c;涵盖了数据库对象的各个方面。 一…

基于Java中的SSM框架实现学生网上请假系统项目【项目源码+论文说明】计算机毕业设计

摘要 本学生网上请假系统是针对目前学生网上请假系统的实际需求&#xff0c;从实际工作出发&#xff0c;对过去的学生网上请假系统存在的问题进行分析&#xff0c;结合计算机系统的结构、概念、模型、原理、方法&#xff0c;在计算机各种优势的情况下&#xff0c;采用目前最流…

大文件切片上传 So Easy?分享 1 段优质 JS 代码片段!

本内容首发于工粽号&#xff1a;程序员大澈&#xff0c;每日分享一段优质代码片段&#xff0c;欢迎关注和投稿&#xff01; 大家好&#xff0c;我是大澈&#xff01; 本文约 1100 字&#xff0c;整篇阅读约需 2 分钟。 大文件切片上传&#xff0c;我一般会分为4步来搞&#xf…

liosam编译问题

编译过程 因为lego安装时已经安装了gtsam因子图优化库,所以不需要再安装 直接编译即可 catkin_make -j8 报错实例 示例:[lio_sam_imuPreintegration-2] process has died,[lio_sam_mapOptmization-5] process has died 解决方法 实际问题是库文件libmetis.so 的位置。…

数据结构与算法:顺序表和链表

目录 一、线性表 二、顺序表 三、链表 一、线性表 线性表&#xff08; linear list &#xff09;是n个具有相同特性的数据元素的有限序列。线性表是一种在实际中广泛使用的数据结构&#xff0c;常见的线性表&#xff1a;顺序表、链表、栈、队列、字符串... 线性表在逻辑上是线…

MyBatis框架学习笔记(一):MyBatis入门

1 MyBatis 介绍 1.1 官方文档 MyBatis 中文手册&#xff1a; &#xff08;1&#xff09;https://mybatis.org/mybatis-3/zh/index.html &#xff08;2&#xff09;https://mybatis.net.cn/ Maven 仓库&#xff1a; https://mvnrepository.com/ 仓库作用&#xff1a;需要…

(三)前端javascript中的数据结构之集合

集合的特点 1.无序 2.唯一性 3.不可重复 集合相对于前面几种数据结构&#xff0c;比较简单好理解&#xff0c;看看代码实现就能知道他的用法了 集合的创建 function MySet() {this.item {}; } MySet.prototype.has function (value) {return value in this.item; };//增 M…

编程范式之函数式编程

目录 前言1. 函数式编程的定义2. 函数式编程的特点2.1 纯函数2.2 不可变性2.3 高阶函数2.4 惰性求值 3. 函数式编程的应用场景3.1 并行计算3.2 数据分析3.3 Web开发 4. 函数式编程的优缺点4.1 优点4.2 缺点 5. 代表性的编程语言5.1 Haskell5.2 Scala5.3 Clojure 6. 示例代码结语…

Java中常见的消息中间件有哪些,各自的优缺点是那些?

1、ActiveMQ 优点&#xff1a; Apache基金会开发的开源消息中间件&#xff0c;支持JMS规范。 提供多种集群模式和高可用机制。 易于使用&#xff0c;并且与多种编程语言交互良好。 缺点&#xff1a; 在处理大量消息和并发连接时&#xff0c;性能可能不如其他中间件。 对于大型…

状态模式在金融业务中的应用及其框架实现

引言 状态模式&#xff08;State Pattern&#xff09;是一种行为设计模式&#xff0c;它允许对象在内部状态改变时改变其行为。状态模式通过将状态的相关行为分离到独立的状态类中&#xff0c;使得状态转换更加明确和简洁。在金融业务中&#xff0c;状态模式可以用于实现交易状…

legoloam算法环境配置和调试笔记

安装gtsam 参考 Ubuntu20.04安装gtsam记录_gtsam安装-CSDN博客 mkdir buildcd buildcmake .. make -

简谈设计模式之设计原则

设计模式是软件工程中解决特定问题的通用解决方案。这些模式提供了设计结构和最佳实践&#xff0c;帮助开发者创建灵活、可重用和可维护的代码。 设计模式分类 创建型模式 用于描述"如何创建对象", 它的特点是“将对象的创建和使用分离”. 包括单例, 原型, 工厂方…

负载均衡(Load Balancing)、集群(Cluster)和分布式(Distributed)

负载均衡&#xff08;Load Balancing&#xff09; 定义&#xff1a;负载均衡是指将网络流量或计算任务均匀地分配到多个服务器或计算资源上&#xff0c;以提高系统的整体处理能力、可靠性和响应速度。 特点&#xff1a; 流量分配&#xff1a;负载均衡器根据一定的算法&#x…

HTML5新增的input元素属性:placeholder、required、autofocus、min、max等

HTML5 大幅度地增加与改良了 input 元素的属性&#xff0c;可以简单地使用这些属性来实现 HTML5 之前需要使用 JavaScript 才能实现的许多功能。 下面将详细介绍这些新增的 input 元素的属性。 属性说明属性说明placeholder在输入框显示描述性或提示性文本list为文本框添加选…

React+TS前台项目实战(二十七)-- 首页响应式构建之banner、搜索、统计模块布局

文章目录 前言一、 效果展示二、相关模块1. Statistic统计模块功能分析代码详细注释使用方式 2. Search搜索模块功能分析代码详细注释使用方式 3. banner模块功能分析代码详细注释使用方式 总结 前言 前面我们已经封装了这个项目基本要用到的全局组件了&#xff0c;现在就开始…

ScreenAI ——能理解从信息图表到用户界面的图像和文本算法解析

概述 论文地址&#xff1a;https://arxiv.org/pdf/2402.04615.pdf 信息图表&#xff08;图表、示意图、插图、地图、表格、文档布局等&#xff09;能够将复杂的数据和想法转化为简单的视觉效果&#xff0c;因此一直以来都被视为传播的重要元素。这种能力来自于通过布局和视觉线…

在Pycharm中把jupyter notebook转换成md格式

在Pycharm的控制台输入&#xff1a; jupyter nbconvert --to markdown filename.ipynb这里实际上是用的nvconvert 同理&#xff0c;如果是在vscode中写jupyter&#xff0c;也可以用&#xff1a; jupyter nbconvert --to FORMAT notebook.ipynb将其变成ipynb文件&#xff08;…

普通人必看!AI绘画商业变现全攻略(附教程)

大部分的设计师除了主业以外&#xff0c;都会利用空余时间去接单做副业。 单子包括但不限于产品/品牌LOGO、电商产品图设计、海报、室内设计图等等&#xff0c;单价在几十到上千不等 引起了我的思考&#xff0c;我们普通人有没有机会&#xff0c;也能像他们一样去接单赚钱吗&a…

pytorch- RNN循环神经网络

目录 1. why RNN2. RNN3. pytorch RNN layer3.1 基本单元3.2 nn.RNN3.2.1 函数说明3.2.2 单层pytorch实现3.2.3 多层pytorch实现 3.3 nn.RNNCell3.3.1 函数说明3.3.2 单层pytorch实现3.3.3 多层pytorch实现 4.完整代码 1. why RNN 以淘宝的评论为例&#xff0c;判断评论是正面…