Hey, all right, everybody. Lee Lowell here, smartoptionsow.com. It's 2022. Welcome to our first 2022 edition of the Saturday Synopsis. Been a couple of weeks. It took the last few weeks off at the end of 2021. Regroup, take a little time to relax, spend some time with the family, and raring to go now. 2022, let's make it a good year, everybody. So what do we do here in the Saturday Synopsis? Well, we look at charts. We look at indexes, we look at individual stocks. I'm here to show you what I do, what I've learned over my 30 years in the business. I'm a technical analyst. That's what means I look at the charts, try to help me gauge when to get in and get out of trades. It's all about chart reading. That's all that I do. So I make these free videos and I try to show you what I'm seeing on the charts. So let's just jump right in and today is Saturday, January 8th, 2022. So let's go right in. For those of you who've been here for a while, you know that I look at the daily charts, okay? There's lots of time frames that you can look at. I look at a daily chart because I'm more interested in a longer timeframe. Months, weeks, years, there's guys out there that look at very short time frames, one minute charts, three minute charts, and that's fine if that's what you're willing to do. That's not what we do. And on the charts here, what you're seeing right here, I've got the price action up here. This is the SPY, which is the exchange traded fund for the S&P 500. I believe it gives us the best overall view, the broadest view of the market as a whole. So we tend to look at that first. And on my charts, each line here, vertical line is one day's worth of trading and these are open, high, low, closed bars. These are not candlesticks. And we have some technical indicators. Down here I have the RSI, the 14-day RSI. It's an overbought, oversold indicator. And down here, this one I recently added, this is the Stochastics indicator. It's also more of an overbought, oversold indicator. I'm putting this back on, I usually don't use this, I usually just have the RSI, but I'm adding the Stochastics back in here to see if I could fine tune my timing even more. And I've looked at a lot of indicators over the years, a lot. And I used to use Stochastics, when I tried to trade very short-term, I realized I couldn't do it, one minute charts, five minute charts, it's just not for me. And I used the Stochastics back then, it was just too erratic. But on a longer-term timeframe, daily charts, I think the Stochastics, I don't know why I'm having such a problem saying that, can give us some decent timing. So I'm trying to see if it adds value to my chart reading. And so this is the Stochastics, and here is the parameters. I know a lot of people ask me, what are the parameters? It's 12, 26, and nine. Those are the three numbers that define what the Stochastics are. And also with the RSI indicator, it's just a 14-day RSI indicator. So I try to use these overbought, oversold indicators to help me gauge when we can get in and out of trades. But really the price action up here is what we're looking at. So this is the daily chart of the S&P 500 by the SPY. And if you've been with us for a while, you know, we've been bullish, or I've been bullish. Stock market's been in a nice uptrend. And I draw these lines on the charts. You can see we have, you know, W pattern, triangle patterns, channels, channels. These are all things to help you gauge, you know, when a stock may be topping, when a stock may be bottoming. It just helps with your timing a little bit better, okay? So what we see here is that, so a couple weeks ago, when was the last one I made? I guess it was New Year's Eve was the last one. I mean, so it wasn't really that long ago, or maybe it was two weeks ago. Christmas Eve might have been the last one I made. And so we had the S&P 500 was making all-time new highs. Here's right at the end of the year. Let me see where Christmas was right around here. So the S&P 500 was bumping up against this resistance line. You know, we wanna draw support and resistance to see where a stock may be having trouble getting through or support where a stock may be having trouble getting through on the downside, okay? So the S&P 500 was bumping up against this resistance line here. And then just in the last two weeks, it broke above it. But as we saw the end of this week, we had a decent size move downwards. Not as bad as the NASDAQ, and we'll look at that soon. But the S&P 500 came down back below this resistance line. But it's fallen on support right at the 50-day moving average. These are the, I have three other lines on here. I've got a blue 20-day moving average, this red 50-day, and then this green or orange one is the 200-day moving average. Those are three widely followed moving averages. So you wanna maybe keep those on your charts as well. And the moving averages, depending on which way they're sloping is also important. You know, uptrending stocks would typically have upsloping moving averages. And that just means the stocks or index is in a good momentum pattern and will typically stay in that movement until it changes. So we've got the S&P 500 having a little bit of pullback here. And but it's falling right on support at the 50-day moving average. When stocks are in a certain direction and going in that direction, when they bounce or they have a pullback, you'll notice that they'll pull back to one of the moving average lines, either the 20-day or 50-day. The 50-day is a little bit more important. It's a slower, longer-term type of moving average. I give a little bit more credit to the 50-day moving average, but I keep the 20-day on there as well. And so when you draw these channels, you can see that the stock can bounce in, you know, along the channel, bounce off the bottom, bounce off the top. So you wanna use those channels to try to give you an idea of where the stock may be moving next. So I had mentioned that we have the resistance here. Towards the end of the year, we'd probably make more all-time new highs, which we did, but now, beginning of the year, we've had a little pullback. But we've pulled back to the 50-day moving average, which I think is a good support area. I nibbled a little bit, bought some shares of the SPY on the pullback to the 50-day moving average, and even the 20-day. So I bought a few contracts, a few shares of stock in here, right in this little bottoming area, to see if it's gonna bounce.  So I use these pullbacks to add to my positions, and hopefully, in the long run, the stock market will continue to move higher. Let me pull this down a little bit. Pull these down so we can get some more price action here. So I'm in it for the long run. I'm in for the bullish movement. Pullbacks are part of the game. Pullbacks are going to happen. And as long as we know the stock market is always going to be made up of companies that are having great earnings and profitable quarters, quarter after quarter, the stock prices are gonna go up. And you can use these pullbacks as your timing mechanism to get in long, if that's what you want. That's what I do. Okay, so I'm bullish on the stock market as a whole. Yes, the narrative out there is, inflation is still there, COVID is still there. The US Federal Reserve is going to start raising interest rates in 2022. And that's a little scary for the market. Stocks will tend to sell off when interest rates rise. Why is that? Because sometimes you can get a better return, a long-term return by moving into bonds and out of stocks. So if interest rates rise high enough, people will say, you know what? I'm gonna sell my stocks and I'm gonna buy bonds. And that will typically cause a sell off in the market. But does it last forever? No, does that mean we've maxed out the stock market and now it's just bearish times ahead for the foreseeable future? No, I don't agree with that. There's too many players out there. The stock market has been the greatest wealth generator for the last 100, 200 years even. And so just because interest rates rise doesn't mean that the stock market is a bad investment. So I'm sticking with stocks. I know in the long run stocks go up. Let's take a look at a long-term chart of the S&P 500, okay? So here is the last down move we had in 2008, the meltdown. It's been going up since, yes, we had the pandemic, but it reversed very quickly. So since 2008, stock market's gone straight up. And yes, we know it's because interest rates have been held very low, but it doesn't take away from the fact that companies have been profitable even during that time. So it's not just interest rates being low that the stock market has gone up. Companies are profitable. And if you have a profitable company, the stock share price has to go up. And even I think with rising interest rates, sure, we may have a pullback, but it's not going to stop companies from being profitable. So I like the stock market. I'm in the stock market. But what we do here at the smart opposite sellers, we trade, we make trades. So we have to gauge where a stock or index may be going in the near term. Our trades typically last one to three months out in time. So that's our timeframe. So we have to gauge on that short amount of time where the market's going. So we do need to be pretty precise with our timing. But in the long run, I'm bullish. So I'm looking for this 50-day moving average to hold for the S&P 500 and start to move back up. Let's take a look at the NASDAQ because that got hit pretty hard this week.  So the NASDAQ represented by the QQQ, nice, slow, up-moving trend, which is what we love to see. If you're in for the long haul, this is a great trend you want to see. And we draw these trend lines, these blue lines, we draw these, this is the channel and it bounces in between the channel. So if you're looking to get long, you look for it to pull back to the bottom of the channel and see if it bounces. And you could buy here, nibble here, before the bounce. And then when it gets confirmed that the bounce is happening, you could buy some more, right? Every bounce here would have been nice. The market's nice and slow. This is exactly what we like to see. And you can see I have also these triangles in here, these congestion patterns. Also blue lines might be a little hard to see, but in the long game, you can see it continues to move up. Had a little down trending channel here, but that was just the bounce off the top down to the bottom bounces again. Now what we're seeing here is maybe a little bit of a sideways pattern. We can draw more trend lines, maybe have a little bottom support here. Okay, you can draw these lines, try to make this as flat as possible. Okay, and maybe, I don't know, up here a little bit as well. It's not exact, it's not black and white, it's in the eye of the holder. So I may be seeing something different than someone else may be seeing. So we have a little maybe sideways action here until the market figures out, how do we wanna handle this inflation thing, this interest rates, rising thing, COVID. When a stock or index is moving sideways like this, there's a lot of indecision, right? Before people wanna engage in really taking a stake for the next move. So we got a little indecision hitting some support here. So I'm thinking that maybe the market will bounce here starting next week, or it could even come down to the bottom edge of this longer term uptrend. So we'll see. It's not black and white, it's not guaranteed. There's just drawing these lines can help you gauge where a stock or index may be more inclined to bounce off of or get hit resistance and come back down. The more of these lines that you can, or more of these patterns that you can see potentially can help you get your timing better. So this is what we do, we draw the lines. Now as far as where the stochastics and the RSI lie, these are like right in the middle. So there's really nothing's overbought, nothing's oversold. So these aren't really telling me anything. So I have to rely on the price action. Obviously, when these are in the middle of their ranges, that means we've got some sideways activity going on.  I think if anything, we may bounce here or it may come off a little bit more next week to this uptrending line here. Probably have to start to extend this line, have to redraw this to keep it moving higher. But the moving averages are sloping upwards, which is good. I like to see that if you're bullish, these are all good things. Okay, so let's go back to the SPY real quick just to see what the stochastics and the RSI is looking at, same thing. They're right in the middle of their levels here. Nothing really major overbought, oversold.  So you got this ascending triangle pattern. And if you want to learn more about patterns, you go online, do a Google search on stock chart patterns, something like that, and you'll come up with these websites that'll show what all these patterns are. You got this ascending triangle, you got the channels, you got the W patterns, all these things that you can learn about. All right, so let's look at some individual stocks now and see what happened over the last couple weeks. Let me go back to the top of my chart here. So let's talk about, let's look at Oracle because we've talked about Oracle before. Oracle had this gap up on earnings, the thing popped over $15 a share and it pulled all the way back, which was I liked that because I like Oracle. So we got into some trades in our newsletters on the pullback, some bullish trades. So we sell put options, we sell naked put options, we sell put options, spreads, both bullish trades. And I like how it's finding support right here on the 200 day moving average. You know, this was a good pullback. So if you're looking to get long Oracle, you know, here is your lower risk entry or higher probability entry. It's the 200 day moving average is holding, which is good. Stochastics have gotten down to a lower end of the range here might be ready to turn higher, which could be good. The RSI is not really too oversold. So I think the support here should hold. And you know, Oracle is a great company, but when we sell put options, we take a lot of, we sell put options very conservatively which we use, you know, strike prices way out of the money when we sell put options. Just to give us more cushion in case we're wrong with the direction of the stock, that's what we do. We get a lot of cushion. So we sell out of the money put options and out of the money put option spreads. And so even if we're wrong on the stock move we can still win on the option trade. So like Oracle here, I like how it's finding some support, see what happens, it could bounce and then start heading higher for the longterm. What else do we have? Let's take a look. We always look at Apple. Let's take a quick look at Apple. Open this up. Apple also had made all-time new highs just a couple of days ago, way up here just above $180 a share became the first $3 trillion market cap company in the US, in the US stock market. So Apple fans are happy with that. Long has had a nice move, over $30 a share. Since down here we're bounced off both the 20-day and 50-day moving averages conversion rate, the convert, the, what's the word I'm looking for? Both of the moving averages were right against each other here and the stock moved up. And so we have a little pullback this week. Is that a big deal? I don't think so. In the long run, Apple keeps going up. Great company. So if you're looking to get in, maybe start to look for, will it come down to the 50-day moving average? It's a possibility, depending on how the overall market is next week. I think that if it finds some support here at the 50-day, I may even start to nibble a little bit. RSI had gotten a little overbought here on this move here. So it did kind of call a little top here, but the RSI starting to move lower, which the stock price action has been moving lower as well. Stochastic's maybe a little bit overbought here, starting to turn down a little. So maybe we'll see a little bit more pullback in Apple, maybe to the 50-day moving average. So keep an eye on it. We know it's a great company in the long run. It's going to keep going up. Let's take a look at Tesla. This is just all kinds of analysis. This is not any kind of recommendations. This is just what I'm seeing on the charts.  It's very hard to gauge with traditional, technical analysis what Tesla wants to do because it can be very erratic, very erratic. It was in this nice channel, then it powered higher. It was in a congestion pattern here. The triangle came out below, bounced again, came back. So Tesla, for me, I can't really get a gauge on how to do technical analysis on Tesla because it's just a crazy stock. So I don't invest in Tesla. It's too much for me, too expensive, too volatile. I like to watch it just to see what it's doing. But I give a lot of credit to those of you who can trade in and out of Tesla. It's just too hard. I'm gonna remove some of these lines here because they don't really seem to make much sense anymore. So you remove those lines, maybe you can get a better view of the stock when you take some stuff away and kind of see where it may be going. Am I seeing anything different here than what I saw before? It's kind of hard. It's kind of hard to see. Maybe we had, at this point, we had a little bit of a down-trending channel here, which now Tesla has broken out, but has come back down in. So it could be finding support here. 20-day moving average, maybe it'll bounce or maybe it'll come all the way back down to the lower edge of this channel. Hard to say. Tesla's just crazy. So hard to say what it wants to do. But if you like Tesla, it's certainly exciting. That's for sure. All right, let's take a look at some other stocks here that I wanna show you about. Here, let's take a look at Clorox because Clorox is a stock that we talk about quite a bit and I mentioned that I had gotten into some shares. So Clorox, here, let's pull back a little bit. For those of you that are new, Clorox had been going up nicely in the channel and then it started in this new down-trending channel, had some fits and starts. Looked like it was maybe going up again but it continued into this down-trending channel. And since last summer, July or so, August had been stuck in this sideways channel and I said, if it can get above maybe 174-175, could be time that Clorox has finally made the bottom. And it had been sideways. So when it popped above, right here, I'm gonna show you what it did, when it had this little section right here, it got above all the moving average, 20-day, 50-day, 200-day. So right in here, I got long around 174-175, $176 a share, right in here. And I thought that was the breakout. Now, we had some fake breakouts before but I never jumped on those. But this was my time to get in, bought some shares here and then it came back down. But what it did was it found support on the 20-day moving average here. So I bought in here, came down here, holding on because I believe we've got the uptrend behind us now. And now Clorox has come all the way back from 168, 169 and closed just under 180 yesterday. So it looks like Clorox is making a move. I'm up a little bit on the position. I'm hoping that it's going to now find its way higher and start its long journey back up. So that's what I wanted to show you on Clorox. What was the other one that I wanted to show you? Let's take, let me scan the stocks here and see what we've got here. Oracle looked at AMD. Okay, let's take a quick look at AMD. We love AMD, but could be some more selling ahead. You know, made all-time new highs here. Been pulling back. Let's move out to the monthly chart for a second. Yep, okay, so we're all-time highs here. What are we seeing? Price action's coming down. Do we have support? Do we have support right around here? Possible, possible. Gonna keep an eye on it. We do have a position in AMD, but way out of the money. So we have a lot of cushion. Let's keep an eye on it. You know, the R-sized moving lower, Stochastic's moving lower. So we could have some more selling ahead. How much? Hard to say. I like to see this level hold here and bounce and get ready to make all-time new highs. But you know, at the moment, keeping an eye on AMD. Let's see. Microsoft, Microsoft got hit a little. Still a strong stock. Intel, Nike. Let's take a quick look at Nike here. One of the most famous companies in the world. Great company. Here's the 200-day moving average. This is a very important line. 200-day moving average right here. Pulled back, bounce, pulled back. So, you know, maybe Nike's gunning for the 200-day moving average. 200-day moving average could be a good place to maybe nibble a little bit. What I'm seeing here is the RSI. I mean, the Stochastic's, even though the price action's been moving down, the Stochastic's has sort of found the bottom and starting to turn upwards. Could that mean that the selling is done? The RSI's not really telling me that the selling is over yet. So, maybe we have some conflicting signals here. I'm gonna keep an eye on Nike. If it gets down to the 200-day moving average, then I'll take a look. Maybe the RSI will be a little bit more oversold. That could mean, all right, maybe it's time to nibble here a little bit. Keeping an eye on Nike. We know it's a great company. Long-term, let's take a quick look. Once again, monthly.  So, long-term, we know Nike's a profitable company. What else do we have here? Apple, Amazon still stuck in that range, getting close down to the bottom leg of that support and the channel. So, Amazon still can't get its act together. Netflix is another position. So, we had a position in Netflix, which we had to get out of yesterday, Friday, January 7th because it was just moving down too much for us and we hit our stop points. So, yes, we do have some trouble sometimes with trades. That's just how it is. You can't win everything.  You don't wanna let it turn into big losses. Ego is a very hard thing to get over in this business. You can't let your ego dictate. Have your rules and when it's time to get out, you get out. Can't win them all. But, Netflix just, the tech stocks got hit pretty good. Netflix has fallen from $700 a share to under $550. That's a big move. That's a big move. It is getting close to some oversold levels though. So, it could find some support, but we don't know where that eventual bottom will be when it finally support comes around. Could the bottom be here? Yeah, the bottom could be at 500. We just don't know yet. Netflix can move a lot in a very short period of time. Stochastics, kinda leveling out here, which is possible for bottoming action and the RSI getting close to oversold levels. So yes, maybe Netflix might be getting to a bottom here, but still don't know yet. When it starts to move sideways, then we'll know whether that's the bottom, okay? But while it's still in this kind of free fall, you don't wanna try to pick bottoms yet. And when your system tells you to get out, you get out. So Netflix will keeping eye on that for maybe a potential trade in the future. Let's look at PayPal, because I talked about PayPal in the past. PayPal also came down a long way, but the sideways action is telling me, and I said this in the last synopsis, that PayPal could be near term trade, bullish trade because it's finding its footing here and maybe ready to turn higher and go up. The, you can see the RSI got into some oversold level. So here's this vertical, this horizontal line is my lower edge of oversold area at the 20 level. So it's got some oversold here and you can see the stochastic's got below its lower level here and turning higher. So you got some sideways action, but yet the RSI's moving up, stochastic's moving up. That could mean that PayPal's just getting ready to turn itself higher. So we'll keep an eye on PayPal. Now Square is the other one in the sector, payment sector that I like as well. Still going down, I chose PayPal versus Square because PayPal was making that sideways action. Square just seems to be going down RSI. We may have a little bit of divergence, but that I mean is when the price action is still going down, you can see the RSI, just the slightest uptrend here, not making new lows like the price action, but starting to go up a little. And you can also see the stochastic's are just kind of treading along the bottom edge of the oversold, but slightly moving higher. So that could mean that Square is finally starting to possibly find a bottom here, selling maybe slowing down. So keep an eye on Square. I really don't think it's got that much more downside to go. I'd like to see some sideways action before maybe pulling the trigger on Square to get long. So these are the things that you want to look for when you're looking for trades. Cisco, looking decent, finding some support at 20-day moving average, Procter & Gamble, great company, just been going up nicely. Walmart, let's take a quick peek at Walmart. Had to support long-term support here right around 135, made a nice bounce. So Walmart's in a bit of an uptrend here. Low, past few weeks, a little bit of uptrend. So it could be, just staying sideways, maybe making some more highs here in the near future. Walmart's a great company though, but this is probably, we can even draw another line here. Another, maybe the top of the channel here. So that's Walmart. It'll probably fluctuate. I'm hoping to see it bounce up long. I am long Walmart, just to let you guys know what's happening. So I want to see Walmart go up. Disney, yeah, let's take a quick look at Disney. We talked about Disney before, got really oversold here. It actually pinpointed the bottom pretty good. Nibbled on some shares here. Stochastics also turned up right from that same point. So Stochastics moving up, RSI moving up, and you can see the price action has been moving up too. What I like here is that it's trying to maintain itself above the 50-day moving average. If it can remain above the 50-day moving average for a few more days, we could probably see it maybe try to get back up to the resistance line or the support line, the one-time support line here around 170.  I think it's on its way, it's on its way. And I think 170 is the next price that it should tackle. Not on Monday or Tuesday, but over the ensuing weeks, maybe even a month or two, that get back up to 170 and see where it goes from there. What else? Whoopsie, let's fix this here for a second. Tesla we looked at. So the pharmaceuticals, Lily, Bristol Myers, Pfizer, Merck. You know, healthcare is great for long-term. It has some fits and starts. Merck was surprising. We actually got out of our trade on Merck profitable, put-sell trade that we did. Finally, we got out. Kellogg, oh, let's talk about Verizon. Okay, so we talked about Verizon quite a bit. I've been telling you for months now. Love Verizon, but it had been in this downtrend. So it wasn't worth getting into it yet. Still downtrend, downtrend, downtrend, but December, it started to move higher. It got out of the, it actually finally popped above the upper leg of this long downtrend. Right here, the last few days, up here. What happened? Well, it looked like you got a bull flag going here. So bull flag is when you have this long up move. Okay, let me edit this a little bit so you can see what I'm talking about. Okay, so you got the long flag pole it's called. And then you have the pennant here and here. This is called a bull flag. Let me edit these a little bit as well. Okay, you got the bull flag and the pennants. And the pennants, come on. Let's edit this one too. Give a little color, some depth, width. Okay, so now we see the bull flag. This is a bullish pattern. You get the long flag pole and then the down trending pennant. And typically the blast should be to the upside. It came from the downside, made the long pole, had a little bit of a pullback and it also bounced right around the 20 day and 50 day right where they were converging right here. Bounced, which is good. So what I'm seeing here is that we finally got above this long down trending channel. Maybe even making another bull flag. So cautiously optimistic on Verizon here. If it could get above this down sloping 200 day moving average, which isn't that far ahead, maybe around $55, $56 and hang around there and it can continue on. Then I feel, okay, Verizon has finally found its footing. Yeah, we didn't get the bottom at 50, but sometimes you're gonna get a lot of false starts. If you've been trying to buy from back here, you've been very disappointed. So you're not always gonna catch the bottom. It's better to wait for the signals to tell you it's time to get in. You won't catch the bottom, but maybe you'll get on for a nice leg higher. So I'm thinking, you know, Verizon maybe nibble here just to see or wait till it gets above the 200 day moving average, 55, 55 and a half dollars for a couple of days. And then Verizon could start to move higher in a good way. So I'm keeping an eye on Verizon. All right, so let's quickly look if there's anything else. I'm sorry that I don't know what my mouse is doing here. It's jumping all over the place. Okay, what else? Same thing with AT&T. Looked like it was doing the same thing as Verizon. Little double bottom here. PayPal we looked at. Costco pulling back to support 50 day moving average. Costco is just a very strong, strong company. Let's move this over here. Let's move this. Okay, so now, come on. McDonald's still McDonald's looks good. It's just a strong company, right? Just keeps has this nice low uptrending move. So McDonald's is a strong company. Pepsi, even McDonald's Pepsi. Oh, I like Coca-Cola. I wanted to bring that up as well. Pepsi looks strong. Coca-Cola also looks strong. I think Coca-Cola hitting. Let's see if they're hitting all time new highs here. Yep, Coke just made all time new highs. I love it. Long Coke myself. Great dividend. Finally got off its butt here, right? It's a sort of double bottom and has been moving higher. Got about $10 movement here in the last month or so. That's pretty good for Coke, $10 move. What else we got? Twitter, Twitter still kind of moving down. Let's take a quick look. Stochastics found this deep oversold bottom here, right? Called it right around here. Did bounce a little bit, it's come back down. But here's the divergence again. So we've got the price action moving down, but you can see the RSI is not making new lows. Sort of uptrending here. Same with Stochastics, uptrending. So maybe Twitter is finally starting to find a bottom here. Have to wait and see. Have to watch the price action. Maybe it'll start to trade sideways for a little and then curl and go higher. So it's always good to wait for the confirmation. That'll be a higher probability trade. If you're trying to pick bottoms, don't go all in. Maybe nibble a little bit. If you think we bottom, maybe nibble.  All right, so I don't like Facebook. It's just got trading sideways anyway. What else we got here? Bitcoin stocks. We got Riot, Mara, those are all kind of coming down. Bitcoin prices coming down. Peloton, that one's been really hard for a lot of people. eBay was another trade that we got out of for profit. Even though it came down in price, we still made profits by selling put options. Alibaba, I don't really track that much, Clarks, we looked at, all right. So that's about it. I think we're done here. Market looks strong still. In the long game, it looks strong back to the SAP 500. We're gonna have pullbacks. That's just part of the market. That's what happens, okay? But we've got this support here, uptrending support. I think in the next couple of weeks to market, you're gonna see we got more all-time new highs. Gunning for that 500 mark slash 5,000 mark on the SPX index itself, this is one tenth the size of the S&P 500 index. So if we look at the, I'll bring it up the SPX itself, right? It's about, you know, it's 10 times larger than the SPY. So here's that 5,000 mark. Could be gunning for that in the next, I don't know, couple months. That's what I'm thinking. All right, that's it for the Saturday synopsis. I hope this has helped you a little bit. Let's quickly, oh wait, let's look at one other thing, because someone asked me about Warren Buffett and you know, how his fund is doing. So I think I have that on here. Do I have that? Let me see, let me type it in. Okay, so here's the Berkshire Hathaway. The class B shares, $319 a share, just has had a massive move. It got out of the, so here was in a channel and it just blasted higher. So Warren Buffett's doing some good things these days. And I'm gonna show you something that I have on our site that could possibly intrigue you about Warren Buffett. So that's it for the Saturday synopsis. Let's quickly go to our website and show you what we got there. You know, we're big put option sellers at the smart option seller, that's what we do. Go to our website, smartoptionsseller.com and right here, put selling basics along the top is our free guide on how to sell put options. Scroll down, put in your name and email address and we'll send you a free copy. What we do here is we have some newsletters, click on our services tab. We have our smart option seller and our vertical spread trader newsletter. We also have our coaching to help you become a better option trader. And speaking of the Warren Buffett, let me show you what we have here.  The secret to buying Warren Buffett for pennies on the dollar. It does cost money.  I don't really advertise it too much but you can, you saw the stock, stock's going up. So it could be worth your time. All right, that's it. I hope this YouTube video has been good for you, helpful. I like to show you what I do. Give me a thumbs up, leave me a comment. Send me an email. I love hearing from you. And I hope everyone has a great trading week ahead. 2022, let's make it a good year. I read everyone. This is Lee Lowell signing off.


Welcome back to the Riffamonis Reproducible Research Tutorial series. I hope you're able to make it to the last tutorial where we added an R script to our driver file to generate a figure with an ordination plot. I'm constantly amazed by the growing number of resources that are available in both R and Python to make our data analyses more reproducible. One of these new resources is R Markdown. This is a blend of Markdown, which we've already discussed when talking about documentation, and R code, which we discussed in the previous tutorial. R Markdown has revolutionized how my research group approaches scientific publisher. Emerging from the Python ecosystem, there's a similar tool called Jupyter Notebooks. Both R Markdown and Jupyter are examples of literate programming in which native text is blended with computer code. The results are pretty marvelous. Have you ever had to update numbers in a manuscript after changing a parameter, using a different statistical analysis, or adding more data? It's painful. More than one time, I've had errors slip into my manuscripts because I forgot to update all of the numbers. And tables with dozens of values? Ah, what a pain. Literate programming removes that pain. If you look at my papers from my research group that are posted on GitHub, you can find R Markdown documents that contain R code behind any summary statistic or p-value. The tables are generated by R code. Furthermore, combined with the idea of a driver script, which we've been developing in this tutorial series, not only can you find the code for the summary statistic, but you can track it all the way back to a raw data file. If you remember back to the introduction for this series, I mentioned an April Fool's joke we played introducing a write.paper function into mother. Well, R Markdown is basically that function. I can't wait to show you how to write research reports and manuscripts using R Markdown. Join me now in opening the slides for today's tutorial, which you can find within the reproducible research tutorial series on the riffamotus.org website. Before we get going and discussing literate programming with R Markdown, I have a brief pop quiz for you that will hopefully jog your memory in how we can work with R from our pipeline. So the question is, how would you run a function? So for example, we saw before plotNMDS from our R script, which is also called plotNMDS.R at the bash shell prompt. Take a couple moments and see if you can look back through your notes or if you remember off the top of your head how you would go ahead and run this function from this R script without first going into R. So hopefully that jogged your memory and you had some recollection of doing this in the previous tutorial. But recall that we can use r-e to execute a string of commands from the bash command line. And so that needs to be, those commands need to be embedded within single or double quotes they need to match. And the individual commands can be separated with a semicolon. So here, bound within double quotes, we have two commands. We have a source function and a plotNMDS function. The source function loads the code from code plotNMDS.R. That file name is wrapped in single quotes. And then we run plotNMDS and that takes a .axis file that is also wrapped in single quotes. And that's a long file name. So again, if we run this from the bash command prompt, we don't have to go into R, but the code will still get run and then it will quit out of R. And so this is really nice if we want to be able to automate our pipeline because we can run R code without actually having to manually go into R. So for today's tutorial, I hope to help you learn how to express a manuscript as an extension of a programmatic analysis to really see that typing and writing our text, our narrative can be fused with programmatic analyses. And this is what we call literate programming. Within R Markdown, they use code chunks and inline code to insert information into the text. So we'll talk about how to do that. And we'll also implement advanced R Markdown features, including citations, figures and tables to make it more of a polished manuscript. And then we'll talk about YAML and YAML material that can be used to impact the format of your output. So looking at this paragraph that you've already seen and copied into your main readme file, this is the paragraph called Scaling Up from the Kozitch analysis. You'll notice that there's a variety of numbers in here that we had to calculate somewhere, right? So down here, there's an error rate of 0.07% for the two mock communities, another 0.01% for the curation, and we had 14,094 sequences. All of these numbers would need to be updated if we changed the data set, if we changed how we calculated error, if we changed any steps in the pipeline. And if you look at this one paragraph, there's maybe a dozen or so different numbers that are being generated elsewhere, right? And so here in these red rectangles are those numbers that we had to calculate somewhere, right? So whether it's the number of samples, a citation number, numbers of sequences, numbers of reads per sample, and so forth, p-values, that we had to generate somewhere and then insert into the text. Similarly, here's a table from that same paper where there's maybe 100 or so different numbers that if we, again, changed the pipeline or if we added another run of data, we would have to update this table. And that could just be a royal pain because you're sure to introduce all sorts of errors in doing that. And so to think about what goes into a paper beyond the narrative, we have things like counts, the numbers of things, we have calculated values, we have p-values, we have references, figure numbers, the actual figures and tables themselves. Each of these can be added and addressed into a paper, into a manuscript using literate programming. Literate programming is the idea that we can merge code with text generation and formatting. Literate programming is developed and championed by a world-renowned computer scientist named Donald Knuth. And currently there are several modern options. So as I mentioned in my introductory remarks, there is Jupyter and R Markdown from the Python and R environments, respectively. From these types of literate programming, we can get many types of output, whether it's a Markdown plain text file, PDF, a Word.x file, or HTML code for rendering on a website. Thinking about R Markdown, there's a lot of applications that have come out of the ability to use R Markdown in the packages R Markdown and Nitter, which are two packages we'll use that work together. People have used R Markdown to write books, create slide decks, blogs, and interactive websites. It's been really powerful. I liken it to a cookbook, that if you go into Amazon and look at the reviews for a random cookbook, invariably you'll find reviews that say, this cookbook described how to make these types of cookies, but the cookies taste awful. Well, think about a slide deck where you're teaching R or you're showing somebody your code and your figure. It's like giving someone the cookie and the recipe used to make the cookie, right? Well, we can have the plot or the p-value and the code right there with it to know how those values were calculated or how those images were generated. I have taught entire semester-long courses using slide decks built using R Markdown. And why we're here discussing this today is that I write now manuscripts entirely in R Markdown. And again, if we think about this paragraph and the various values that we might want to calculate using R, we can now look at this example of R Markdown. Not all of the numbers have been converted to R Markdown, but you might look over here and you'll see these back ticks with R and then R code embedded. This R code, when it's rendered by Knitter and R Markdown together, will spit out a number telling the reader how many pairs of reads there were per sample. And so this is going to be pretty foreign to you right now, but by the end of this tutorial hopefully you'll understand what's going on here. So hopefully you recall that we previously used Markdown in the paper airplane example and in our readme files for providing documentation. R Markdown is the idea that we can take that Markdown and embed R code into it to generate text, tables, and figures. The R Markdown package from R uses the Knitter package and other goodies to convert R Markdown files into a variety of formats. And so you can see the schematic from R Studio where you write in R Markdown use Knitter to convert that to Markdown and then a program called Pandoc will convert that Markdown into a variety of formats. This whole pipeline is fairly opaque to you. All you need to worry about is writing the R Markdown, setting what the output you want it to be, and you'll get it. And that is all done using the programs Knitter and R Markdown. So the outputs we can get include Markdown for basic text. And again, if we were to look at this on a site like GitHub where it automatically converts Markdown to HTML, that would serve our purposes. Alternatively, we can generate HTML-based websites. This is really nice for lab reports and affords you limitless formatting options using HTML, CSS, JavaScript if you want. You can also write, have things outputted as a DocX file. This is great for manuscripts. We find that it's easier for our collaborators to work with the DocX file than say the R Markdown file. There is a bit of a limited formatting issue. You can format using a template.x file where in that template file you provide the formatting that you want. Things like what font do you use, what size, double spacing, line numbering, things like that. We can also output PDFs. I find that this is my preference for manuscripts, but I find that it's harder for my collaborators to work with because they tend to want to get into the text and mess with it and do things like track changes and all the things they're used to doing. But there is then limitless formatting via LaTeX. And so you don't need to know LaTeX to generate a PDF, but it does then allow you to have more options in formatting. There are various helpers within the new project directory template that we'll talk about later. And so again, there's a range of outputs for papers. You need to find what works best for you and your collaborators in terms of the output. So we can do all of this through RStudio. They also have a nice notebook-like interface and they have various helpers to make things easier. But we're not going to use RStudio. I'm sorry. Because we're trying to emphasize the importance of having a workflow that's automated and can run without our intervention. Having to then go into a graphical interface kind of limits that. I'm also assuming that you'll likely want to run everything on a cluster and may not be able to run a graphical interface on your server. I know that there's a huge barrier to using a graphical user interface on my local Flux cluster or even going on to Amazon. So what we're going to do is to return to our Kozic analysis. We're first going to log into our instance and start FileZilla so it'll be easier to transfer files back and forth and see what's being generated. Previously in the tutorial on organization, you copied the scaling up paragraph into your readme file. We're going to move that now to our submission practiceRMD file. So this practiceRMD file is going to be a new file that will generate. And we'll use for practicing various aspects of using our markdown. So I've been able to log into my instance and I'm going to go ahead and move to my Kozic reanalysis AM 2013 directory. And we're in the right place. So again, I'm going to open my readme file and I see my scaling up paragraph here. I'm going to copy that, scroll X out, and I said nano submission practice.RMD. And that gets me my scaling up. And I forget if my readme also had the figure legend, it doesn't look like it. So I'm going to open back up submission practice.RMD. And I'm going to copy the figure legend for figure four. So again, this is a bit artificial because rarely would we want to go back and add the R code. You certainly can, but it's much easier to write the R code as you're actually writing the paper. Okay, we'll save this and exit out. Next, we'd like to go ahead and look at our .rprofile file. So if we do ls, you'll notice we don't see a rprofile file, but if you do ls-a, in here, the bottom right, we have a .rprofile file. This is the file that is loaded whenever we run r. Now we talked about in the last tutorial that we don't want to put a lot of stuff into this .rprofile file. So let's see what's in there. So we'll do nano.rprofile, and it says library nitter, library rmarkdown. And then it sets paths for where to put things from nitter and from rmarkdown. And it helps to normalize our path and to get things in the right place. So everything looks good here. One other thing I'll add is that the AWS instance you have has nitter and rmarkdown already installed. So you don't need to install packages for rmarkdown or nitter. We'll go ahead and reopen our submissionpractice.rmd file, and we're going to start the process of converting this into an rmarkdown document. At a minimum to make it an rmarkdown document, we need to add what's called a yaml header. So a yaml header is denoted by having three hyphens on the first line, some information, and then three hyphens to close the yaml header. In between the three hyphens, we need to add information that tells rmarkdown and nitter and pandock eventually what exactly needs to be done. So in here we'll put output colon space HTML document. So our yaml headers will get a little bit more complicated as we go along, but it's important to note that we never want to put a tab in our yaml header. Any kind of justification along the left side, left margin, we want to do with spaces. So we'll go ahead and save and quit this. And so then from our command line, we can render this doing r-e, quote, render, single quote, submission-practice.rmd, single quote, parentheses, close quote. Remember we don't need to put our markdown or library nitter in here because that's automatically loaded as part of our profile file. So we'll run this and it runs pretty quickly. And we see output created practice.html. So I need to connect to my AWS instance in FileZilla and I need to update my IP address and I'm going to get that from my AWS instance. Copy it to the clipboard, come back over here, paste that in, connect. Yes, I'll trust them, okay. Cosetree analysis, submission-practice.html, opening that up. I see I now have a HTML formatted version of the scaling up file. That's great. So at a basic level, we see that it works. So let's add a title, date, and author to our yaml. So I'm going to reopen my submission-practice file and I'm going to add title. And I'll say, reproducing Kozic et al. Author, I'm going to put my name in, you put your name in, patch loss. Date, and I'm going to say April 24th, 2018. And I'll go ahead and save this and quit. And then back out in my, in Bash, I'm going to render this and I can then go to FileZilla. I can refresh and refresh here. Maybe I need to double click again on it. Reopen local file. Discard local file, then download and edit file anew. Okay, so now we see we have a title. Lost the all. My name and my date. So it nicely puts in this information that we added into the yaml header. So I'll return to my RMD file. And if we look down in here, we see that there's a couple numbers here. The 4.3 million pairs of sequence reads from the 16S RNA gene with an average coverage of 9,913 pairs of reads per sample. With 95% of the samples had more than 2,454 pairs of sequences. What I'd like to do is to automate those calculations in my RMD file. So to do this, we'll need to create what's called a code chunk. And we'll also need to make use of what's called inline code. A code chunk is denoted in R markdown by three back ticks, a curly brace, an R and a curly brace. And then the code chunk ends with another set of three back ticks. So if you have a bunch of paragraphs in your paper, you can have code chunks scattered throughout your document. Because our document is pretty small here, we're only going to have one code chunk. And so because this isn't an R course, I'm going to copy the notes, the code, I'm sorry, from the slide deck into the code chunk here. And so we see, I'm going to add some spacing here so we can kind of differentiate what's going on. So we've got our shared file name. We're reading in our shared file with the R code. We're counting the number of sequences in each row. And then we're getting the sequence counts in millions by counting up the number of sequences divided by a million, the average sequence counts using the mean function, and then the percentile sequence counts here in this final line of the code chunk. So this is the code that's going to be used later in the paragraph to embed into our sentence. And so this 4.3 million is going to come from this million sequence counts. And so these three variables hold information that's going to go into this paragraph using what I'm calling inline code. All right, so 4.3 million pairs. I'm going to remove that 4.3 and put in a back tick, R, and I have another back tick. And so this means between the back ticks we're going to put R code that's going to be run and inserted directly into the sentence. So I'm going to say million sequence underscore counts. Similarly, down here we have average coverage. I'm going to replace this with R, back tick, R. And inside the back ticks, I'm going to put average sequence counts. And then in here, the 95% of samples had more than 2,454 pairs of sequences. I'm going to do, again, back tick, R, back tick. And inside the back ticks, I'm going to put percentile sequence counts. All right, so see how we did that? We have a code chunk up here that reads in the file. It does the calculations. And then down here in the narrative part of the text, we can call on these variables that were defined up here in the code chunk to be inserted in directly. Now, we could have put everything in this code chunk directly into the inline code, but that would get really painful to read and difficult to edit later. And so, again, we can use this code chunk to define variables that we then insert into the text. So I'm going to go ahead and save this and re-render. But average sequence counts not found. So I'm going to check that out again. And I misspelled sequence up here in my code chunk. Save that, re-render. Everything worked. I'll come over to FileZilla, refresh, reopen. I'm going to discard and then download the file anew. Aha! And so now what we see is that we have our code chunk. And then in this sentence, where we put our R code, we see we generated 3.86 million pairs of sequence reads, with an average covered of 1.07, blah, blah, blah, times 10 to the 4 pairs of reads per sample. Okay? So the information is here, but the formatting leaves a little bit to be desired. So how well did we reproduce the previous results? Well, the numbers are pretty close. The Kozich paper originally was not generated using an R Markdown document. They're pretty close. There were two data sets available, so it's possible we grabbed the wrong data set or that I used a different date. There was one data set that was the with metagenomics and one was without the metagenomics. We may have grabbed the wrong one that I used originally. We could go back and check that out. There have also been software changes to mother over the years. That might cause some things. There's also some randomness at different steps in the pipeline. And it's also possible that the total number of sequences was really the number of raw sequences. And what we have here is the number of curated sequences that made it through our pipeline. And so these are all things that would have been nice if we would have documented it the first time around. We have since gone back and regenerated this paper using reproducible practices. And the numbers are pretty close. And the gist of the story doesn't change. So this is really cool, right?  And so let's just think about what we've done first. We've created a code chunk. That reads in the file and it does some processing of the data. When we submit it, we probably don't want to see the code. We'd like to hide that. But for our PI or select collaborators, we might want to show them the code so that we have proof of our methods and they can see what we've done. The inline code, the number of significant digits is a bit over the top. So what we're going to first do is look at how we can get rid of seeing this code chunk. We still want it to run, but we don't want to see it. So if we go back into our markdown document, inside our curly braces after the R, we can write echo equals false. What echo equals false will do it will not echo the code. So echo equals true is what we currently have where it echoes back the code to the screen. So we quit out. We re-render. And now the code chunk is gone, but the results of our R are still in the sentence. So there's some other code chunk options that are useful. So include tells whether the code and results should be in the output. It will still run the code. Echo tells whether the code but not the results should be in the output. It will still run the code. Message true or false tells whether messages that are generated by the code should be in the output. And then warning true or false tells whether warning messages that are generated by the code should be in the output. In the slide deck, there's a link to many other options that are available for how to format figures, do things like caching, make dependencies between code chunks, but again for most of what I do in my papers I'm mainly using echo message and warning in my code chunks. One of the things that we tend not to think about when we use r a lot is how to format text or to format numbers. Normally we're happy to pull a p-value, pull a summary statistic out of r but with our markdown we really want to pull it into another document so we need to think about how we format things. So returning to submission practice, if I scroll down to where I embedded my r code I probably want to round this number that we had as output and we can do this with a function called round and format and so I can say format, round, million sequences, million sequence counts and so for rounding I'm going to say a round to one significant digits and then for format I'm going to say n small equals 1l close parentheses and what this will do is this will return a single digit or a number with a single one significant digit nothing to the right of the decimal point so if we save render open that up so we see that we've got one significant digit to the right of the decimal point 3.9 which is what we were hoping for so that's a lot tidier. We can do the same type of thing we can do the same type of thing with the other numbers that we generated so if we go back to nano and we look at our average sequence counts we can do the same thing where we round it to one significant digit format round comma 1 comma n small equals 1l close parentheses and we'll do the same thing here with our percentile where we'll do format round 1 1l quit render and so we see much nicer formatting so we have 10,735.1 pairs as the average instead of you know something in scientific notation and then 2,788.9 pairs of sequences so in this sentence we had three numbers 3.9 10 735.1 2788.9 that were all generated from r if we return to our r code and we we look down at this we might notice that this isn't very dry that we have the same format round and then the number and the same parameters over and over again and so what we'd like to do let's perhaps remove this so we don't have to repeat it but that our text can be formatted or numbers can be formatted the same way every time we're outputting text what we'll do is we'll go up and we'll create another code chunk and i'm gonna we can name our code chunk so i'm going to name this one nitter settings and i'm going to say eval equals true so we're going to evaluate what's in here our echo is going to be false and we're going to say cache equals false let me close that with three back ticks and in here i'm going to set several chunk options so we can globally set our chunk options so i'm going to say ops chunk dollar sign set parentheses tidy equals true and i'm going to copy this several times so i don't have to keep typing so we'll do tidy equals true tidy refers to how the code is formatted echo equals false we've already seen fault echo where it outputs the code chunk eval equals true warning equals false and cache equals false you might want to run this a couple times with warning equals true you might want to run once with warning equals true just to make sure you're not getting any problematic warning or error messages when you run your analysis so if you look at the slide deck there's a function in the slide deck called inline hook that i'm going to copy and paste into here and this is a function that is run every time it does an inline code chunk okay wherever you see that back tick r and then r code it runs this function on the contents within those back ticks and so you'll you'll see that there's information in here on what to do some of this we don't need to worry about is it a list unlist it and spit it out as a vector but if it's numeric then it does different things so it'll format it with commas and no no special digits for formatting if it's not scientific or if it's not an integer it will again use commas and it'll use one significant digit and it won't use scientific notation so this first one is saying is it an integer if it's an integer don't use a decimal if it's not an integer then use one significant digit and so what this allows us to do then is to go back into our code our inline code and to reformat the text the other thing is that this code chunk would be a great place to load any libraries that we had to run so we could source any utilities or we could library any packages that we're using in here and so again we can come down to our text and we can remove these format round function calls from here and here so we can save this and exit out render it and we see that we have the same formatting of our text but the text is much more dry some other things we'll want to deal with include figures and tables references and then other output formats and so that's what we're going to spend the rest of this tutorial discussing my preference in working with figures in a manuscript is to not generate the figure within my rmd file well if you're using an rmd file as a notebook like we saw in the meadow at all paper then that makes sense to leave it in there but normally when i'm submitting a manuscript i have to submit the figures separate from the text and so and also sometimes the figures require a fair amount of code to generate and i like to encapsulate that away into a separate file but we can still see the figures show up in our rmd in our output from our rmd file and and that is using our markdown code so let's go back into our practiced rmd file and i'm going to come to the bottom where i have my figure legend and under that we can use markdown to insert an image so i'm going to and the syntax is type and then i'll talk so the syntax is as you see here and that we use an exclamation point square bracket and inside the square bracket is the description if you're familiar with html this is like the alt attribute for an image tag and then we give the path to get to the figure all right and so i'm going to change my description to be figure one and then the path to figure is going to be a little bit weird because we need to give it a relative path to our submission directory so we're going to do dot dot slash results forward figures forward nmds underscore figure dot png and if we save this and render hopefully that figure will now be inserted into the output of our rmd file and sure enough there is our figure now i could get rid of the text inside the description and that figure one will go away i don't really want to see that and again it's gone now okay so that's how i tend to insert figures if i'm going to put figures into a manuscript again when you submit a manuscript frequently you're not going to put the figures in with the figure legends but if you're doing it for a a report to give to your pi or a draft then it's nice to be able to put the figures in with the manuscript so we're going to go ahead and add a silly table to our our markdown document and i'm going to put this at the end because normally i have tables at the end of my manuscripts and because this isn't a tutorial on r necessarily i'm going to go ahead and create a code chunk and copy the code over from the slide deck so there's my my code chunk frame and i'll add this as a table one is the name of my code chunk the names aren't critical sometimes it's helpful for debugging where things go wrong because it'll give you an error message of of where where problems happened so i'm going to go ahead and copy and paste this code from the slide decks over in and you can see what's perhaps what's happening is that we make a column for days number of samples per days mean samples per day per sample the total sequences per days and then we have a loop that goes through and counts these things but then we're we get to the table is that it it makes a data frame that has four columns unique days so what are the days of the study the mean sequences per day per sample so how many sequences do we have per day per sample the total sequences by day and then the number of samples we have by day this then gets us into cable which is that package that function i'm sorry in our markdown that will build a nice table for us we give it our name of our data frame next comes digits which is the number of numbers to the right of the decimal point that we're going to use in formatting our table we're not going to use any row names our column names are going to be day seeks per sample mean br is a bit of html to put in a line break sequences per day total and number of samples finally we tell cable to align our columns to be the center and and so just to show you a little we can we can give this as a string where each letter in the string tells you whether tells knitter where where whether it should be center right left center whatever um where you want the number positioned horizontally within the table so if we save this we render it we then load it from file zilla and we see that we get a data frame so if you recall we made the first column left formatted center right center okay and also we said zero digits to the right for the day one one to the right for column two zero and zero for the other two columns as well so we can put in some nice formatting and again this is all html and if you know some css you could format this to look um a bit more like a bit more polish or a bit more like you would like it to look but again this is a bit of a silly example telling us for each day of the mouse study how many sequences we have per sample the total number of sequences across all of our samples for that day and the number of samples that we have so you see that you know on day 302 we had one sample but on day zero we had 12 samples from our 12 different mice so again this is how we can put a figure and now a table into our our markdown document the next thing that we want to be able to do is to put references inside of our R code and one of the things that we need to tell it is what type of formatting we want to use and so there's a variety that will work with our markdown word and latech and so we can find these in what's called the csl github repository which you can find in the slide deck a link to we commonly use style guides for the asm journals and there's a copy of that called mbio.csl in the directory csl so if we um submission you'll see here there's mbio.csl and so we can see the csl github repository we can see the csl repository by going to the github repository citation style languages slash styles and you'll see in here any number of journals represented and you can search for the one you want because there's so many of them up here so if we did I spelled American wrong American nope that's right and so oh we see one for applied environmental microbiology or a variety of the asm journals in here so if we wanted applied environmental microbiology we would copy this file and then pop this into our submission directory and we would name it and so this is what we've done but with the mbio.csl and returning to our markdown document we'll need to make a couple of changes to our we'll add to our yaml header we'll say csl mbio.csl and then we also need to tell it where our bibliography is so we'll do bibliography dot bibliography equals references dot bib and we'll save that but now we need to create references.bib and we'll also have to insert our references into our text here so we'll quit out of that and we will create a reference file we'll do submission references sorry nano submission references dot bib and by default we put in here the mother paper so Schloss 2009 and this is the type of formatting that we need to represent our our papers and so I want to get two out of here and so one is the original paper that these data were taken from and so I will go to PubMed and the authors on that were Schloss Schubert, Zacular and that's this and I'm going to copy this doi number and there's a nice tool called doitobib.org and we can give it a doi a PMCID or an archive ID and so if I hit enter on that I get nice bibtech formatted material so I can copy that and I can go back in here and I can paste that in and so now I've got these two and the other file that I want is the other paper sorry that I want is if I go back to PubMed is Clayton and MKUJC and this is the theta yc and so we need to get the doi number so I'll click on the paper now there's the doi and so I can click this doi and go back to doitobib so I can copy that now into my references.bib file and now I have three files or three papers represented in my bib file so to cite these in our manuscript you now want to go back into submission practice rmd and we want to replace this 18 with our reference so we'll do square bracket at Schloss 2012 and this is coming from our references file so if you scroll down till we had Schloss 2012 this is the name that we're going to cite Schloss 2012 similarly if we wanted to use um cite the theta yc this u 2001 would be what we'd cite so let's go ahead and put that in and scrolling to the bottom we have this 28 we're going to see that that was at u 2001 I'll quit that and we can then render it this runs through we then open up this and we see u clayton has a two and the original mouse study has a one and if we scroll to the bottom we see our references so maybe we'd want to say we'd want to add said nano submission at the bottom we could put in and double pound references so we have references and then list of our references and that's pretty sweet right so we can do references can do tables we can put figures into our our markdown documents so as I mentioned before there's a lot of different output formats that we can get from our our markdown documents and this is all going to be set in that yaml header material we've already seen how we can output html as I mentioned we can output markdown we can output word document files pdf's and many others each of these formats have many many many options that are constantly being updated and added so I'd encourage you if you're interested in that to check on those click on those links and to go to the our markdown site where they have really great documentation on how you can customize the output further i'm going to give just brief description of how we can do different things we've already seen with html using output html document with markdown we can say output equals md document we can also do a word document so word underscore document it's a little bit beyond what i want to do right now but we have the ability to generate a template to customize the formatting it's can be a little bit limiting there might be ways to figure out line numbers but it's it's not trivial it's problems with some problems with table formatting bulleted lists and no forced line breaks so but at the same time people you're working with are going to want a word file so what we generally do is we generate the word file knowing that we're going to send it to collaborators we then manually format it to get the fonts and the spacing and everything the way we want it and we send them the word file that maybe takes five minutes to to kind of take what we get as a word file out of knitter to convert into what we we want to send to our collaborators PDF is also a powerful tool you but you first have to have a full installation of tech on your system to render it as a PDF i think it render offers the best possible output look but there's a bit of a learning curve and there's a variety of things that you're going to have to add using letek we have some help things built into the new project template that we're going to be using here in a minute we can also generate output that's a combination of various types PDF word markdown whatever you want perhaps one collaborator wants a PDF one wants a word document you know go crazy i'll often render a PDF and a word version for me and my collaborators respectively because i like working with a PDF i like the way it looks it feels good to me of course others want a word document so they can do track changes i still like to get a pen and kind of mark things up manually so we also have this new project rmd template that was in there you'll notice in the submission directory there is a file called manuscript rmd and we will render that as we did for practice rmd and so hopefully you'll see what's similar and what we're going to do is to copy what we had from that scaling up paragraph into the results section of our manuscript and we're going to go ahead and re-render what we had there so again if we do ls submission we see down here that we have manuscript rmd and i should add that tech comes pre-installed with this amazon image and like i said earlier if you want to render to pdf you have to install tech on your own and there's instructions on how to do that on the rm the rmarkdown website that's linked through those slide notes so let's open up manuscript rmd and we see that there's some built-in yaml material here for you there's also this set of um knitter settings for you that's already here and we've got a running title space name is for your authors this is the cover page you could customize this the way you want there's an abstract um various sections of the paper so if you were writing a paper you could take this template and you could populate all these sections and then we've got figure legends references and so forth so what we're going to do is i'm going to copy the material from practice into manuscript rmd so the submission practice i'm going to use cat to output submission practice rmd and this will make it easier for me to copy and paste so i'm going to grab this code chunk all the way down to here copy nano submission manuscript rmd and i'm going to throw this in my results section and then i'm going to take my figure four and my figure copy that and put this down at the bottom and replace this here great save that back out so again what we've done is we've taken our results are scaling up paragraph put it into the results section of of this manuscript rmd file i'm going to save it and now to render it again we can do r-e quote render submission manuscript rmd single quote parentheses double quote we run that it will generate manuscript pdf for us and go to go to file zilla we see that we now have manuscript pdf we'll download this and we see we get out name of study we could update this stuff if we wanted of course and so here in our results and discussion scaling up paragraph that has again the code we added in our inline code and again here's our figure this is a png file so it's the quality is pretty poor but you know we could update that and fix that as well right so again we've seen how to output a html file as well as a pdf file and looks pretty nice we've got line numbers i've got that cover page that we could update and and fix a bit to get it ready for submission so as a closing note we can also put code into our header material so here's a way to put whatever today's date is in as the date we're using our assist time to get the time the date that it will then go into the date for our report we can also feed in parameters like a function treating the our markdown document like a function where we might say have grade reports or something like that that we're doing for a class or some monthly report that we're doing for kind of updating a project we can run that by feeding it specific data files to generate kind of reproducible report reports where the underlying data is changing and it's then reflected in the output into the report we've really done a lot today with our markdown documents and thinking about how we can use our markdown documents to make research reports as well as manuscripts that embed code into our science narrative of course what we're going to want to do before we quit is to commit as well as logout of aws but before you do i would really encourage you to edit your scaling up code in paragraph further to automate the printing of another number or two from that paragraph you might also see about generating a figure using the data in the shared file that we imported in that code chunk another question for you to think about if you have code in a say a utility script called code utilities.r or something else like that where would you run that source command to load the functions from that utility.r file i feel strongly that our markdown and other literate programming tools are a huge step forward in improving the transparency and reproducibility of any analysis not only can someone rerun the code to generate the paper but they can see the code used to generate the numbers in the manuscript within the context of the actual text describing the relevance of the results we saw our markdown documents before when we looked at the meadow paper published in the journal microbiome if you look back at that file you notice they used our markdown to generate what you might consider a research notebook type of document that's a great way of walking people through an analysis in a less rigid manner than we typically see in a manuscript my preference is to also make those type of documents but to use them more in a data exploration phase of a project and to use the tools we talked about today to prepare a polished manuscript that's ready for submission next time we'll go all in and actually write our own write.paper function that allows us to start from an empty directory and end with a pdf version of our manuscript we'll be using a tool called make that will allow us to make our driver script more sophisticated and will allow us to restart the pipeline at any step in the workflow talk to you next time