• 主页
  • 课程

    关于课程

    • 课程归档
    • 成为一名讲师
    • 讲师信息
    同等学历教学

    同等学历教学

    免费
    阅读更多
  • 特色
    • 展示
    • 关于我们
    • 问答
  • 事件
  • 个性化
  • 博客
  • 联系
  • 站点资源
    有任何问题吗?
    (00) 123 456 789
    weinfoadmin@weinformatics.cn
    注册登录
    恒诺新知
    • 主页
    • 课程

      关于课程

      • 课程归档
      • 成为一名讲师
      • 讲师信息
      同等学历教学

      同等学历教学

      免费
      阅读更多
    • 特色
      • 展示
      • 关于我们
      • 问答
    • 事件
    • 个性化
    • 博客
    • 联系
    • 站点资源

      未分类

      • 首页
      • 博客
      • 未分类
      • WGCNA 加权基因共表达网络分析教程(1)

      WGCNA 加权基因共表达网络分析教程(1)

      • 发布者 weinfoauthor
      • 分类 未分类
      • 日期 2019年10月16日
      • 评论 0评论

      学是很多做科研的同学都想学的,包括我在内,现阶段正在学习这个,深夜整理材料不易,请多多关照支持!

       

      img

      先安装Rstudio以及以及加载WGCNA数据包

      Rstudio软件下载地址:

      https://www.rstudio.com/products/rstudio/download/

      WGCNA加载按照网站步骤操作:

      https://labs.genetics.ucla.edu/horvath/CoexpressionNetwork/Rpackages/WGCNA/

       

      范例CSV文件下载地址:链接: https://pan.baidu.com/s/1bTS30Vr080RXjJuj0-3cEg 密码: pcs4

      Workshop可以在rstudio菜单栏的session-set working directory 选择你要工作的文件夹,要读取的CSV等文档都只能放在设置的working directory。

      蓝色#表示注释行,黑色是代码,运行代码时的每一行命令是不需要分号“;”。

       

      以下是代码数据,这个是我看学习的教程,有些我也不懂,粘贴出来一起学习。

       

      1.a Loading expression data

       

      # Display the current working directory
      

      getwd();

      # If necessary, change the path below to the directory where the data files are stored.
      # "." means current directory. On Windows use a forward slash / instead of the usual \.workingDir = ".";setwd(workingDir);
      # Load the WGCNA package
      library(WGCNA);
      # The following setting is important, do not omit.
      options(stringsAsFactors = FALSE);
      #Read in the female liver data set
      femData = read.csv("LiverFemale3600.csv");
      
      # Take a quick look at what is in the data set:
      dim(femData);
      names(femData);
      
      

      #The expression data set contains 135 samples. Note that each row corresponds to a gene and column to a sample or auxiliary information.(创建原始表达数据集datExpr0)

      datExpr0 = as.data.frame(t(femData[, -c(1:8)]));#去掉femData数据集中第一列至第八列后的数据集
      
      names(datExpr0) = femData$substanceBXH;
      rownames(datExpr0) = names(femData)[-c(1:8)];
      

      1.b Checking data for excessive missing values and identification of outlier microarray samples

       

       

      gsg = goodSamplesGenes(datExpr0, verbose = 3);
      gsg$allOK
      

      #If the last statement (gsg$allOK)returns TRUE, all genes have passed the cuts. If not, we remove the o↵ending genes and samples from the data:

       

      if (!gsg$allOK)
      {
        # Optionally, print the gene and sample names that were removed:
        if (sum(!gsg$goodGenes)>0)
           printFlush(paste("Removing genes:", paste(names(datExpr0)[!gsg$goodGenes], collapse = ", ")));
        if (sum(!gsg$goodSamples)>0)
           printFlush(paste("Removing samples:", paste(rownames(datExpr0)[!gsg$goodSamples], collapse = ", ")));
        # Remove the offending genes and samples from the data:
        datExpr0 = datExpr0[gsg$goodSamples, gsg$goodGenes]
      }
      

      #Next we cluster the samples (in contrast to clustering genes that will come later) to see if there are any obvious outliers.(样本聚类筛查异常值,异常样本sample F2_221, see Fig. 1)

      )

       

      sampleTree = hclust(dist(datExpr0), method = "average");# Plot the sample tree: Open a graphic output window of size 12 by 9 inches
      # The user should change the dimensions if the window is too large or too small.
      
      sizeGrWindow(12,9)#pdf(file = "Plots/sampleClustering.pdf", width = 12, height = 9);
      
      par(cex = 0.6);
      par(mar = c(0,4,2,0))
      plot(sampleTree, main = "Sample clustering to detect outliers", sub="", xlab="", cex.lab = 1.5, cex.axis = 1.5, cex.main = 2)
      

      img

      # Plot a line to show the cut
      abline(h = 15, col = "red");# Determine cluster under the lineclust = cutreeStatic(sampleTree, cutHeight = 15, minSize = 10)table(clust)# clust 1 contains the samples we want to keep.
      
      keepSamples = (clust==1)
      datExpr = datExpr0[keepSamples, ]
      nGenes = ncol(datExpr)
      nSamples = nrow(datExpr)
      

       

      #The variable datExpr now contains the expression data ready for network analysis.

       

      1.c Loading clinical trait data(加载临床处理数据)

       

      We now read in the trait data and match the samples for which they were measured to the expression samples.

       

      traitData = read.csv("ClinicalTraits.csv");
      dim(traitData)
      names(traitData)
      # remove columns that hold information we do not need.
      allTraits = traitData[, -c(31, 16)];
      allTraits = allTraits[, c(2, 11:36) ];
      dim(allTraits)
      names(allTraits)
      # Form a data frame analogous to expression data that will hold the clinical traits.
      femaleSamples = rownames(datExpr);
      traitRows = match(femaleSamples, allTraits$Mice);
      datTraits = allTraits[traitRows, -1];
      rownames(datTraits) = allTraits[traitRows, 1];
      collectGarbage();
      

      #We now have the expression data in the variable datExpr, and the corresponding clinical traits in the variable datTraits. Before we continue with network construction and module detection, we visualize how the clinical traits relate to the sample dendrogram.(将表达数据集datExpr和datTraits作聚类图,Fig.2)

       

      # Re-cluster samples
      sampleTree2 = hclust(dist(datExpr), method = "average")# Convert traits to a color representation: white means low, red means high, grey means missing entry
      
      traitColors = numbers2colors(datTraits, signed = FALSE);# Plot the sample dendrogram and the colors underneath.
      plotDendroAndColors(sampleTree2, traitColors,
                        groupLabels = names(datTraits),
                        main = "Sample dendrogram and trait heatmap")
      

       

      img

       

      #将datExpr和datTraits数据集保存至FemaleLiver-01-dataInput.RData,下次继续使用数据集

       

      save(datExpr, datTraits, file = "FemaleLiver-01-dataInput.RData")
      

       

      贴出来主要是为了相互交流学习

      请关注“恒诺新知”微信公众号,感谢“R语言“,”数据那些事儿“,”老俊俊的生信笔记“,”冷🈚️思“,“珞珈R”,“生信星球”的支持!

      • 分享:
      weinfoauthor
      weinfoauthor

      1233

      上一篇文章

      实例解读| lncRNA在胃癌中的作用 | 高分SCI发表(第十二期)
      2019年10月16日

      下一篇文章

      Realtime-PCR的包
      2019年10月16日

      你可能也喜欢

      2-1675088548
      lncRNA和miRNA生信分析系列讲座免费视频课和课件资源包,干货满满
      30 1月, 2023
      9-1675131201
      如何快速批量修改 Git 提交记录中的用户信息
      26 1月, 2023
      8-1678501786
      肿瘤细胞通过改变CD8+ T细胞中的丙酮酸利用和琥珀酸信号来调控抗肿瘤免疫应答。
      7 12月, 2022

      留言 取消回复

      要发表评论,您必须先登录。

      搜索

      分类

      • R语言
      • TCGA数据挖掘
      • 单细胞RNA-seq测序
      • 在线会议直播预告与回放
      • 数据分析那些事儿分类
      • 未分类
      • 生信星球
      • 老俊俊的生信笔记

      投稿培训

      免费

      alphafold2培训

      免费

      群晖配置培训

      免费

      最新博文

      Nature | 单细胞技术揭示衰老细胞与肌肉再生
      301月2023
      lncRNA和miRNA生信分析系列讲座免费视频课和课件资源包,干货满满
      301月2023
      如何快速批量修改 Git 提交记录中的用户信息
      261月2023
      logo-eduma-the-best-lms-wordpress-theme

      (00) 123 456 789

      weinfoadmin@weinformatics.cn

      恒诺新知

      • 关于我们
      • 博客
      • 联系
      • 成为一名讲师

      链接

      • 课程
      • 事件
      • 展示
      • 问答

      支持

      • 文档
      • 论坛
      • 语言包
      • 发行状态

      推荐

      • iHub汉语代码托管
      • iLAB耗材管理
      • WooCommerce
      • 丁香园论坛

      weinformatics 即 恒诺新知。ICP备案号:粤ICP备19129767号

      • 关于我们
      • 博客
      • 联系
      • 成为一名讲师

      要成为一名讲师吗?

      加入数以千计的演讲者获得100%课时费!

      现在开始

      用你的站点账户登录

      忘记密码?

      还不是会员? 现在注册

      注册新帐户

      已经拥有注册账户? 现在登录

      close
      会员购买 你还没有登录,请先登录
      • ¥99 VIP-1个月
      • ¥199 VIP-半年
      • ¥299 VIP-1年
      在线支付 激活码

      立即支付
      支付宝
      微信支付
      请使用 支付宝 或 微信 扫码支付
      登录
      注册|忘记密码?