0% found this document useful (0 votes)
8 views

R-code

Uploaded by

anumsaeed095
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

R-code

Uploaded by

anumsaeed095
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

> if (!

requireNamespace("BiocManager", quietly = TRUE))


+
+ install.packages("BiocManager")
>
> BiocManager::install(c("DESeq2", "GEOquery", "ggplot2"))
'getOption("repos")' replaces Bioconductor standard repositories, see
'help("repositories", package = "BiocManager")' for details.
Replacement repositories:
CRAN: https://cran.rstudio.com/
Bioconductor version 3.18 (BiocManager 1.30.22), R 4.3.3 (2024-02-29 ucrt)
Installing package(s) 'DESeq2'
trying URL 'https://bioconductor.org/packages/3.18/bioc/bin/windows/contrib/4.3/
DESeq2_1.42.1.zip'
Content type 'application/zip' length 2396005 bytes (2.3 MB)
downloaded 2.3 MB

package ‘DESeq2’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in


C:\Users\PMYLS\AppData\Local\Temp\RtmpMZmNVd\downloaded_packages
Installation paths not writeable, unable to update packages
path: C:/Program Files/R/R-4.3.3/library
packages:
boot
Old packages: 'bdsmatrix', 'curl', 'data.table', 'digest', 'GenomeInfoDb',
'locfit', 'RcppArmadillo', 'S4Arrays', 'tidyselect'
Update all/some/none? [a/s/n]:
n
Warning message:
package(s) not installed when version(s) same as or greater than current; use
`force = TRUE` to re-install: 'GEOquery' 'ggplot2'
> library(GEOquery)
Loading required package: Biobase
Welcome to Bioconductor

Vignettes contain introductory material; view with


'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.

Setting options('download.file.method.GEOquery'='auto')
Setting options('GEOquery.inmemory.gpl'=FALSE)
> library(DESeq2)
Loading required package: S4Vectors
Loading required package: stats4

Attaching package: ‘S4Vectors’

The following object is masked from ‘package:utils’:

findMatches

The following objects are masked from ‘package:base’:

expand.grid, I, unname
Loading required package: IRanges

Attaching package: ‘IRanges’

The following object is masked from ‘package:grDevices’:

windows

Loading required package: GenomicRanges


Loading required package: GenomeInfoDb
Loading required package: SummarizedExperiment
Loading required package: MatrixGenerics
Loading required package: matrixStats

Attaching package: ‘matrixStats’

The following objects are masked from ‘package:Biobase’:

anyMissing, rowMedians

Attaching package: ‘MatrixGenerics’

The following objects are masked from ‘package:matrixStats’:

colAlls, colAnyNAs, colAnys, colAvgsPerRowSet, colCollapse,


colCounts, colCummaxs, colCummins, colCumprods, colCumsums,
colDiffs, colIQRDiffs, colIQRs, colLogSumExps, colMadDiffs,
colMads, colMaxs, colMeans2, colMedians, colMins, colOrderStats,
colProds, colQuantiles, colRanges, colRanks, colSdDiffs, colSds,
colSums2, colTabulates, colVarDiffs, colVars, colWeightedMads,
colWeightedMeans, colWeightedMedians, colWeightedSds,
colWeightedVars, rowAlls, rowAnyNAs, rowAnys, rowAvgsPerColSet,
rowCollapse, rowCounts, rowCummaxs, rowCummins, rowCumprods,
rowCumsums, rowDiffs, rowIQRDiffs, rowIQRs, rowLogSumExps,
rowMadDiffs, rowMads, rowMaxs, rowMeans2, rowMedians, rowMins,
rowOrderStats, rowProds, rowQuantiles, rowRanges, rowRanks,
rowSdDiffs, rowSds, rowSums2, rowTabulates, rowVarDiffs, rowVars,
rowWeightedMads, rowWeightedMeans, rowWeightedMedians,
rowWeightedSds, rowWeightedVars

The following object is masked from ‘package:Biobase’:

rowMedians

> library(ggplot)
Error in library(ggplot) : there is no package called ‘ggplot’
> url="https://www.ncbi.nlm.nih.gov/geo/download/?
acc=GSE152075&format=file&file=GSE152075%5Fraw%5Fcounts%5FGEO%2Etxt%2Egz"
>
> download.file(url, "raw_reads.gz")
trying URL 'https://www.ncbi.nlm.nih.gov/geo/download/?
acc=GSE152075&format=file&file=GSE152075%5Fraw%5Fcounts%5FGEO%2Etxt%2Egz'
Content type 'application/octet-stream' length 7121083 bytes (6.8 MB)
downloaded 6.8 MB
>
> raw_counts <- read.delim("raw_reads.gz", stringsAsFactors=FALSE, sep = " ")
> clindata <- data[["GSE152075_series_matrix.txt.gz"]]@phenoData@data
>
> rownames(clindata) <- clindata$title
>
> head(raw_counts[,c(1:10)])
POS_001 POS_002 POS_003 POS_004 POS_005 POS_006 POS_007 POS_008
A1BG 0 1 0 0 18 8 0 1
A1CF 0 0 2 0 0 0 0 0
A2M 69 36 84 42 83 46 26 0
A2ML1 2 0 0 0 3 30 0 32
A2MP1 0 0 0 0 21 0 0 0
A3GALT2 0 0 0 0 0 0 0 0
POS_009 POS_010
A1BG 0 1
A1CF 0 0
A2M 93 6
A2ML1 6 0
A2MP1 0 0
A3GALT2 0 0
> all(rownames(clindata) %in% colnames(raw_counts))
[1] TRUE
> #the outcome should be TRUE
>
> all(colnames(raw_counts) %in% rownames(clindata))
[1] TRUE
> #the outcome should be TRUE
> colnames(clindata)[colnames(clindata) == "sequencing_batch:ch1"] <- "batch"
> clindata$batch <- as.factor(clindata$batch)
> colnames(clindata)[colnames(clindata) == "n1_ct:ch1"] <- "ct"
> colnames(clindata)[colnames(clindata) == "sars-cov-2 positivity:ch1"] <- "positivity"
> clindata$positivity[clindata$positivity == "pos"] <- "COVID19"
> clindata$positivity[clindata$positivity == "neg"] <- "HEALTHY"
> clindata$positivity <- as.factor(clindata$positivity)
> dds <- DESeqDataSetFromMatrix(countData = raw_counts,
+ colData = clindata,
+ design = formula(~positivity))
>
> dds <- estimateSizeFactors(dds)
>
> sizeFactors(dds)
POS_001 POS_002 POS_003 POS_004 POS_005 POS_006
0.82150765 1.94503946 1.49097573 1.43709833 3.62733595 4.51302810
POS_007 POS_008 POS_009 POS_010 POS_011 POS_012
0.43879900 0.65560763 1.39349809 0.52104453 0.39175741 1.48338323
POS_013 POS_014 POS_015 POS_016 POS_017 POS_018
1.20106632 0.66727757 2.37800300 0.46610178 0.20797773 1.76775711
POS_019 POS_020 POS_021 POS_022 POS_023 POS_024
2.65142274 1.76886420 1.97030866 0.70447111 0.83783570 0.66872019
POS_025 POS_026 POS_027 POS_028 POS_029 POS_030
0.89108814 2.82454001 0.68920670 1.65203141 5.56849704 0.94758147
POS_031 POS_032 POS_033 POS_034 POS_035 POS_036
0.65483358 0.53204324 1.93439648 0.39280125 0.57118414 0.53233011
POS_037 POS_039 POS_040 POS_041 POS_042 POS_043
0.34756028 0.47397183 0.40659234 0.25446185 0.42860230 0.19437360
POS_044 POS_045 POS_046 POS_047 POS_048 POS_049
0.17275320 1.22474628 0.77871114 0.12095101 0.66709974 0.48064602
POS_050 POS_051 POS_052 POS_053 POS_055 POS_056
1.45778444 2.48142837 0.45258156 0.10172997 0.17053833 1.38160164
POS_057 POS_058 POS_059 POS_060 POS_061 POS_062
1.29123784 0.55072877 0.22723110 0.56090799 0.35834056 0.26984073
POS_063 POS_064 POS_065 POS_066 POS_067 POS_068
0.47723135 0.78893150 2.11919180 0.90699793 0.48525196 1.02668277
POS_069 POS_070 POS_071 POS_072 POS_073 POS_074
1.87880358 2.04558215 2.38657434 1.54185124 2.97612992 0.84452744
POS_075 POS_076 POS_077 POS_078 POS_079 POS_080
7.49339297 1.21680928 1.39623188 1.18920821 1.72370694 3.73009966
POS_081 POS_082 POS_083 POS_084 POS_085 POS_086
0.99115152 0.90122977 0.83929591 3.88800843 0.26679759 1.85159294
POS_087 POS_088 POS_089 POS_090 POS_092 POS_093
2.16993805 6.61679685 0.79220694 0.62224767 1.26100450 0.86008080
POS_094 POS_095 POS_096 POS_097 POS_098 POS_099
0.22813167 0.43758805 0.44854795 1.45678182 0.40660918 1.09052879
POS_100 POS_101 POS_102 POS_103 POS_104 POS_105
1.83335164 3.55862141 0.76396153 0.39301027 1.64352606 1.61382236
POS_106 POS_107 POS_108 POS_109 POS_111 POS_112
0.62527236 1.14875751 0.87637855 5.37132867 1.62077312 0.24354799
POS_113 POS_114 POS_115 POS_116 POS_117 POS_118
3.51304483 2.73965518 1.93933261 2.74366386 0.74948303 0.27978979
POS_119 POS_120 POS_121 POS_122 POS_123 POS_124
0.47153011 0.43800907 0.50394776 2.32665218 0.62008987 2.31793752
POS_125 POS_126 POS_127 POS_128 POS_129 POS_130
0.99220069 2.03392838 0.22334167 0.67704559 2.32969666 0.48883342
POS_131 POS_132 POS_133 POS_134 POS_135 POS_136
0.53514534 0.45261247 0.72774428 0.72577585 0.64276919 3.51469011
POS_137 POS_138 POS_139 POS_141 POS_142 POS_143
0.18067774 1.88115206 1.40814355 0.76515662 1.60223590 0.88027462
POS_144 POS_145 POS_146 POS_147 POS_148 POS_149
1.43963401 0.65839656 0.05540700 0.35236864 0.20813511 1.91410067
POS_150 POS_151 POS_152 POS_153 POS_154 POS_155
0.07650428 0.67487725 0.45105265 0.43339346 1.69155623 0.05019283
POS_156 POS_157 POS_158 POS_159 POS_160 POS_161
0.46078844 0.83930253 0.20510959 1.40537034 1.11178292 7.24019951
POS_162 POS_163 POS_164 POS_165 POS_166 POS_167
0.51851689 1.04121822 0.77355313 1.06525467 0.94935689 2.25489953
POS_168 POS_169 POS_170 POS_171 POS_172 POS_173
0.87628146 0.31268569 0.46983015 1.70957200 0.94406679 1.39192462
POS_174 POS_175 POS_176 POS_177 POS_178 POS_179
3.40383823 1.94774725 0.54670521 0.46047380 0.33685622 0.12765649
POS_180 POS_181 POS_182 POS_183 POS_184 POS_185
0.75606455 3.35223007 0.67548587 2.19360437 0.67183236 2.71454278
POS_186 POS_187 POS_188 POS_189 POS_190 POS_191
0.86494950 1.21993539 0.97910567 2.50798640 0.29825885 0.97967285
POS_192 POS_193 POS_194 POS_195 POS_196 POS_197
0.49169915 0.64665787 1.52663415 0.44409168 0.65953915 1.38778909
POS_198 POS_199 POS_200 POS_201 POS_202 POS_203
1.75246305 0.57304878 0.19125847 1.17950068 0.80035965 1.24036229
POS_204 POS_205 POS_206 POS_207 POS_208 POS_209
0.86344403 1.21692247 0.47680813 2.23865426 0.35572869 2.45584930
POS_210 POS_211 POS_212 POS_213 POS_214 POS_215
1.12638932 0.66480381 0.13646066 1.09477754 1.22109344 1.06264764
POS_216 POS_217 POS_218 POS_219 POS_220 POS_221
0.89569387 4.43385331 1.02481516 1.93410208 0.82905496 0.35154336
POS_222 POS_223 POS_224 POS_225 POS_226 POS_227
0.59248371 1.26566422 1.20728414 0.64244505 1.57791538 0.91876082
POS_228 POS_229 POS_230 POS_231 POS_232 POS_233
5.49855996 3.26113764 2.57206244 0.29095125 4.29115902 0.36134329
POS_234 POS_236 POS_237 POS_238 POS_239 POS_240
0.93756145 0.80413070 4.99509414 0.86380736 3.42879142 0.73288148
POS_241 POS_242 POS_243 POS_244 POS_245 POS_246
1.45869878 1.10855604 0.04013997 0.74576270 1.96759049 1.18448495
POS_247 POS_249 POS_250 POS_251 POS_252 POS_253
3.71692298 11.31606710 2.55147670 1.38604345 3.35309454 0.59140823
POS_254 POS_255 POS_256 POS_257 POS_258 POS_259
1.26495581 0.46507632 1.56513781 1.12561370 1.88594837 0.29517603
POS_260 POS_261 POS_262 POS_263 POS_264 POS_265
2.25030827 1.87961440 1.22437654 0.12453718 1.23359623 0.33468218
POS_266 POS_267 POS_268 POS_269 POS_270 POS_271
0.34376771 1.71780175 0.17010155 0.79511621 0.35210654 0.96247569
POS_272 POS_273 POS_274 POS_275 POS_276 POS_277
0.85895689 0.25033812 0.71824493 1.04186945 0.73034481 0.27359535
POS_278 POS_279 POS_280 POS_281 POS_282 POS_283
0.85724564 1.33676511 1.20124727 0.35374233 0.70733949 0.38453206
POS_284 POS_285 POS_286 POS_287 POS_288 POS_289
2.20831594 0.57290557 0.66315359 0.58636365 1.32666929 0.88244054
POS_290 POS_291 POS_292 POS_293 POS_295 POS_296
1.68949980 0.97307998 0.18268736 1.92722988 1.21571762 0.52147981
POS_297 POS_298 POS_299 POS_300 POS_301 POS_302
0.45089568 0.76762646 0.53159548 2.48967051 1.01910535 1.90993648
POS_303 POS_304 POS_305 POS_306 POS_307 POS_308
0.90335967 9.48393988 0.86630680 25.10848779 6.55766749 1.08771222
POS_309 POS_310 POS_311 POS_312 POS_313 POS_314
0.52786853 1.26456746 4.13002700 2.21255423 2.32132398 0.29894207
POS_315 POS_316 POS_317 POS_318 POS_319 POS_320
0.73862324 0.88613108 4.55930033 1.11748432 3.22116909 0.39079219
POS_321 POS_322 POS_323 POS_324 POS_325 POS_326
1.09513668 1.16927703 1.85012412 0.18985578 0.66196868 0.81364638
POS_327 POS_328 POS_329 POS_330 POS_331 POS_332
0.54969286 0.37761658 0.20494907 0.27667501 0.35714040 0.75757113
POS_333 POS_334 POS_335 POS_336 POS_337 POS_338
2.01587102 1.40169759 0.26393964 0.09279402 0.97126945 0.19179572
POS_339 POS_340 POS_341 POS_342 POS_343 POS_344
1.95474753 1.25568854 0.93456175 0.77785778 2.56274842 0.68100943
POS_345 POS_346 POS_347 POS_348 POS_349 POS_350
0.76437481 1.21416099 0.63417381 0.77094834 0.52882066 1.73103239
POS_351 POS_352 POS_353 POS_354 POS_355 POS_356
0.49109973 0.76349447 1.46427434 5.94220105 3.72030765 2.99336232
POS_357 POS_358 POS_359 POS_360 POS_361 POS_362
1.95199067 4.24926149 2.11426671 2.78373530 2.66847148 2.15866379
POS_363 POS_364 POS_365 POS_366 POS_367 POS_368
0.99813337 0.58707444 3.38615020 9.02672812 1.51376821 1.76615253
POS_369 POS_370 POS_371 POS_372 POS_373 POS_374
1.78379467 4.12942189 4.40204804 0.31802532 4.85824628 1.04779954
POS_375 POS_376 POS_377 POS_378 POS_379 POS_380
0.91546325 1.48488204 0.79519625 2.16997799 0.49333296 1.46388772
POS_381 POS_382 POS_383 POS_384 POS_385 POS_386
1.40262413 0.45137633 2.65718673 0.66674382 0.61703304 3.41946321
POS_387 POS_388 POS_389 POS_390 POS_391 POS_392
3.73637422 1.89777620 4.19211188 1.62392700 0.58213783 1.92832592
POS_393 POS_394 POS_395 POS_396 POS_397 POS_398
2.22045302 1.30687631 1.27050728 1.23931685 3.63717596 1.92744878
POS_399 POS_400 POS_401 POS_402 POS_403 POS_404
1.84911278 1.30140569 1.93450167 0.50514736 1.29997647 0.59868617
POS_405 POS_406 POS_407 POS_408 POS_409 POS_410
1.67579408 1.86980149 1.69006956 5.61899295 2.10884621 0.86825111
POS_411 POS_412 POS_413 POS_414 POS_415 POS_416
9.62551434 1.56271146 2.75351885 0.96724788 1.64361125 0.25153628
POS_417 POS_418 POS_419 POS_420 POS_421 POS_422
1.57934432 0.54330843 0.44028926 0.62898260 0.83088379 0.33791812
POS_423 POS_424 POS_425 POS_426 POS_427 POS_428
1.20302976 0.22366177 0.40970666 0.40435984 0.45548472 0.61097903
POS_429 POS_430 POS_431 POS_432 POS_433 POS_434
1.73742817 3.57972740 2.61260389 3.66782342 1.14744774 0.59514112
POS_435 POS_436 POS_437 POS_438 NEG_001 NEG_002
0.89266608 1.12552906 2.34820749 1.77915572 1.37361248 0.99191586
NEG_003 NEG_004 NEG_005 NEG_006 NEG_007 NEG_008
2.50944161 1.30918020 0.71934137 1.03537857 1.66126743 0.44623436
NEG_009 NEG_010 NEG_011 NEG_012 NEG_013 NEG_014
0.95245375 2.53031524 1.50412382 2.25674763 1.06646617 6.31751393
NEG_016 NEG_018 NEG_019 NEG_020 NEG_021 NEG_022
2.41952118 0.17048801 0.16396356 0.63613827 0.19168077 1.60343400
NEG_023 NEG_024 NEG_025 NEG_026 NEG_027 NEG_028
0.44193872 12.66897032 0.93038627 0.68512621 0.55755191 0.08636394
NEG_030 NEG_031 NEG_032 NEG_035 NEG_036 NEG_037
0.43001183 0.25335642 0.38799176 0.89077939 0.28143092 1.96180106
NEG_038 NEG_039 NEG_040 NEG_042 NEG_043 NEG_046
2.02589805 33.84796729 4.22997327 7.59535344 4.35877734 0.18902771
NEG_047 NEG_048 NEG_049 NEG_050 NEG_051 NEG_052
0.42208111 1.51360842 0.83139662 1.37211524 2.61779054 0.93404869
NEG_054 NEG_055 NEG_056 NEG_057 NEG_058 NEG_059
1.14946016 0.95652615 0.87371970 3.62714412 0.78428673 1.56996972
NEG_060 NEG_062 NEG_063 NEG_065
0.24250539 1.00778315 1.26921554 1.33090346
> dds <- DESeq(dds)
using pre-existing size factors
estimating dispersions
gene-wise dispersion estimates
mean-dispersion relationship
final dispersion estimates
fitting model and testing
-- replacing outliers and refitting for 7069 genes
-- DESeq argument 'minReplicatesForReplace' = 7
-- original counts are preserved in counts(dds)
estimating dispersions
fitting model and testing
>
> res <- results(dds)
>
> summary(res)

out of 31474 with nonzero total read count


adjusted p-value < 0.1
LFC > 0 (up) : 4923, 16%
LFC < 0 (down) : 1582, 5%
outliers [1] : 0, 0%
low counts [2] : 7308, 23%
(mean count < 0)
[1] see 'cooksCutoff' argument of ?results
[2] see 'independentFiltering' argument of ?results

>
> plotMA(res)

You might also like